Skip to content

Commit dcdc3f2

Browse files
authored
slogr: fix unintended API break in v0.8.0 (#253)
* 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.
1 parent 5d88f52 commit dcdc3f2

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.github/workflows/apidiff.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Install Go
1414
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
1515
with:
16-
go-version: 1.20.x
16+
go-version: 1.21.x
1717
- name: Add GOBIN to PATH
1818
run: echo "PATH=$(go env GOPATH)/bin:$PATH" >>$GITHUB_ENV
1919
- name: Install dependencies

slogr/slogr.go

+7
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ func NewLogr(handler slog.Handler) logr.Logger {
4040
return logr.FromSlogHandler(handler)
4141
}
4242

43+
// NewSlogHandler returns a slog.Handler which writes to the same sink as the logr.Logger.
44+
//
45+
// Deprecated: use [logr.ToSlogHandler] instead.
46+
func NewSlogHandler(logger logr.Logger) slog.Handler {
47+
return logr.ToSlogHandler(logger)
48+
}
49+
4350
// ToSlogHandler returns a slog.Handler which writes to the same sink as the logr.Logger.
4451
//
4552
// Deprecated: use [logr.ToSlogHandler] instead.

0 commit comments

Comments
 (0)