Skip to content

Commit bf581b1

Browse files
authored
chore: follow slog api change (#460)
1 parent 964e0af commit bf581b1

5 files changed

Lines changed: 11 additions & 10 deletions

File tree

core/ylog/example_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ func Example() {
3737

3838
// Output:
3939
// level=WARN msg=warn hello=yomo syslog.eee=fff
40-
// level=ERROR msg=error hello=yomo syslog.eee=fff syslog.err=EOF
41-
// {"level":"ERROR","msg":"sys error","syslog":{"ggg":"hhh","err":"use of closed network connection"}}
40+
// level=ERROR msg=error hello=yomo syslog.err=EOF syslog.eee=fff
41+
// {"level":"ERROR","msg":"sys error","syslog":{"err":"use of closed network connection","ggg":"hhh"}}
4242
}

core/ylog/logger_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestLogger(t *testing.T) {
4343

4444
assert.NoError(t, err)
4545
assert.FileExists(t, errOutput)
46-
assert.Equal(t, "level=ERROR msg=error hello=yomo err=EOF\n", string(errlog))
46+
assert.Equal(t, "level=ERROR msg=error err=EOF hello=yomo\n", string(errlog))
4747

4848
os.Remove(output)
4949
os.Remove(errOutput)

core/ylog/slog_handler.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package ylog
33

44
import (
55
"bytes"
6+
"context"
67
"io"
78
"os"
89
"strings"
@@ -73,12 +74,12 @@ func NewHandlerFromConfig(conf Config) slog.Handler {
7374
}
7475
}
7576

76-
func (h *handler) Enabled(level slog.Level) bool {
77-
return h.Handler.Enabled(level)
77+
func (h *handler) Enabled(ctx context.Context, level slog.Level) bool {
78+
return h.Handler.Enabled(ctx, level)
7879
}
7980

80-
func (h *handler) Handle(r slog.Record) error {
81-
err := h.Handler.Handle(r)
81+
func (h *handler) Handle(ctx context.Context, r slog.Record) error {
82+
err := h.Handler.Handle(ctx, r)
8283
if err != nil {
8384
return err
8485
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ require (
1818
github.com/spf13/viper v1.13.0
1919
github.com/stretchr/testify v1.8.2
2020
github.com/yomorun/y3 v1.0.5
21-
golang.org/x/exp v0.0.0-20221212164502-fae10dda9338
21+
golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2
2222
golang.org/x/mod v0.8.0
2323
golang.org/x/tools v0.6.0
2424
gopkg.in/natefinch/lumberjack.v2 v2.2.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
264264
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
265265
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
266266
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
267-
golang.org/x/exp v0.0.0-20221212164502-fae10dda9338 h1:OvjRkcNHnf6/W5FZXSxODbxwD+X7fspczG7Jn/xQVD4=
268-
golang.org/x/exp v0.0.0-20221212164502-fae10dda9338/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
267+
golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 h1:Jvc7gsqn21cJHCmAWx0LiimpP18LZmUxkT5Mp7EZ1mI=
268+
golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
269269
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
270270
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
271271
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=

0 commit comments

Comments
 (0)