Skip to content

Commit e4c2f09

Browse files
authored
fix: correct example to avoid zerolog fields combined (#569)
1 parent 5ca0c41 commit e4c2f09

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

interceptors/logging/examples/zerolog/example_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ import (
1717
// This code is simple enough to be copied and not imported.
1818
func InterceptorLogger(l zerolog.Logger) logging.Logger {
1919
return logging.LoggerFunc(func(ctx context.Context, lvl logging.Level, msg string, fields ...any) {
20-
l = l.With().Fields(fields).Logger()
20+
log := l.With().Fields(fields).Logger()
2121

2222
switch lvl {
2323
case logging.LevelDebug:
24-
l.Debug().Msg(msg)
24+
log.Debug().Msg(msg)
2525
case logging.LevelInfo:
26-
l.Info().Msg(msg)
26+
log.Info().Msg(msg)
2727
case logging.LevelWarn:
28-
l.Warn().Msg(msg)
28+
log.Warn().Msg(msg)
2929
case logging.LevelError:
30-
l.Error().Msg(msg)
30+
log.Error().Msg(msg)
3131
default:
3232
panic(fmt.Sprintf("unknown level %v", lvl))
3333
}

0 commit comments

Comments
 (0)