Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
guangxue.wu committed Oct 31, 2024
1 parent 7104ef8 commit ab6ca38
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions log/global_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,16 @@ func TestGlobalContext(t *testing.T) {
func TestContextWithGlobalLog(t *testing.T) {
buffer := &bytes.Buffer{}

type traceKey struct{}
// set "trace-id" Valuer
newLogger := With(NewStdLogger(buffer), "trace-id", Valuer(func(ctx context.Context) interface{} {
return ctx.Value("trace-id")
return ctx.Value(traceKey{})
}))

SetLogger(newLogger)

// add value to ctx
ctx := context.WithValue(context.Background(), "trace-id", "test-trace-id")
ctx := context.WithValue(context.Background(), traceKey{}, "test-trace-id")

_ = WithContext(ctx, GetLogger()).Log(LevelInfo)
if buffer.String() != "INFO trace-id=test-trace-id\n" {
Expand Down

0 comments on commit ab6ca38

Please sign in to comment.