Skip to content

Commit

Permalink
fix: correct example to avoid zerolog fields combined (#569)
Browse files Browse the repository at this point in the history
  • Loading branch information
levanlongktmt authored Apr 18, 2023
1 parent 5ca0c41 commit e4c2f09
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions interceptors/logging/examples/zerolog/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ import (
// This code is simple enough to be copied and not imported.
func InterceptorLogger(l zerolog.Logger) logging.Logger {
return logging.LoggerFunc(func(ctx context.Context, lvl logging.Level, msg string, fields ...any) {
l = l.With().Fields(fields).Logger()
log := l.With().Fields(fields).Logger()

switch lvl {
case logging.LevelDebug:
l.Debug().Msg(msg)
log.Debug().Msg(msg)
case logging.LevelInfo:
l.Info().Msg(msg)
log.Info().Msg(msg)
case logging.LevelWarn:
l.Warn().Msg(msg)
log.Warn().Msg(msg)
case logging.LevelError:
l.Error().Msg(msg)
log.Error().Msg(msg)
default:
panic(fmt.Sprintf("unknown level %v", lvl))
}
Expand Down

0 comments on commit e4c2f09

Please sign in to comment.