Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
5a9dd890c9 |
22
zerolog.go
22
zerolog.go
@ -214,8 +214,17 @@ func (l *zeroLogger) Log(ctx context.Context, level logger.Level, args ...interf
|
||||
return
|
||||
}
|
||||
|
||||
var attrs []interface{}
|
||||
for _, fn := range l.opts.Options.ContextAttrFuncs {
|
||||
attrs = append(attrs, fn(ctx)...)
|
||||
}
|
||||
|
||||
msg := fmt.Sprint(args...)
|
||||
l.zLog.WithLevel(loggerToZerologLevel(level)).Msg(msg)
|
||||
if len(attrs) > 0 {
|
||||
l.zLog.WithLevel(loggerToZerologLevel(level)).Fields(attrs).Msg(msg)
|
||||
} else {
|
||||
l.zLog.WithLevel(loggerToZerologLevel(level)).Msg(msg)
|
||||
}
|
||||
}
|
||||
|
||||
func (l *zeroLogger) Logf(ctx context.Context, level logger.Level, format string, args ...interface{}) {
|
||||
@ -223,7 +232,16 @@ func (l *zeroLogger) Logf(ctx context.Context, level logger.Level, format string
|
||||
return
|
||||
}
|
||||
|
||||
l.zLog.WithLevel(loggerToZerologLevel(level)).Msgf(format, args...)
|
||||
var attrs []interface{}
|
||||
for _, fn := range l.opts.Options.ContextAttrFuncs {
|
||||
attrs = append(attrs, fn(ctx)...)
|
||||
}
|
||||
|
||||
if len(attrs) > 0 {
|
||||
l.zLog.WithLevel(loggerToZerologLevel(level)).Fields(attrs).Msgf(format, args...)
|
||||
} else {
|
||||
l.zLog.WithLevel(loggerToZerologLevel(level)).Msgf(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (l *zeroLogger) String() string {
|
||||
|
Loading…
Reference in New Issue
Block a user