Skip to content

Commit

Permalink
slogr: fix unintended API break in v0.8.0 (#253)
Browse files Browse the repository at this point in the history
* github: check for API changes with Go 1.21.x

An API break in https://github.com/go-logr/logr/pull/237/files#r1434203442
wasn't noticed because the apidiff tool ran with 1.20.x.

* slogr: fix unintended API break in v0.8.0

logr v0.7.0 had slogr.NewSlogHandler. We must keep that function for API
compatibility. https://github.com/go-logr/logr/pull/237/files#r1434203442
accidentally renamed it.
  • Loading branch information
pohly authored Dec 21, 2023
1 parent 5d88f52 commit dcdc3f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/apidiff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: 1.20.x
go-version: 1.21.x
- name: Add GOBIN to PATH
run: echo "PATH=$(go env GOPATH)/bin:$PATH" >>$GITHUB_ENV
- name: Install dependencies
Expand Down
7 changes: 7 additions & 0 deletions slogr/slogr.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ func NewLogr(handler slog.Handler) logr.Logger {
return logr.FromSlogHandler(handler)
}

// NewSlogHandler returns a slog.Handler which writes to the same sink as the logr.Logger.
//
// Deprecated: use [logr.ToSlogHandler] instead.
func NewSlogHandler(logger logr.Logger) slog.Handler {
return logr.ToSlogHandler(logger)
}

// ToSlogHandler returns a slog.Handler which writes to the same sink as the logr.Logger.
//
// Deprecated: use [logr.ToSlogHandler] instead.
Expand Down

0 comments on commit dcdc3f2

Please sign in to comment.