fixing a subtle bug in With()

dev
Nick Dumas 1 year ago
parent 07e6cab5cd
commit 9eadcedb0b

@ -89,9 +89,13 @@ func (wl *WrappedSlogger) Trace(msg string, fields watermill.LogFields) {
func (wl *WrappedSlogger) With(fields watermill.LogFields) watermill.LoggerAdapter {
attrs := LogFieldsToSlogAttrs(fields)
loggerArgs := make([]any, len(attrs))
for idx, attr := range attrs {
loggerArgs[idx] = attr
}
newLoggers := make([]*slog.Logger, 0)
for _, l := range wl.loggers {
newLoggers = append(newLoggers, l.With(attrs))
newLoggers = append(newLoggers, l.With(loggerArgs...))
}
return &WrappedSlogger{loggers: newLoggers}

Loading…
Cancel
Save