From 9eadcedb0b7305235ee7734c3a8b56661dca0938 Mon Sep 17 00:00:00 2001 From: Nick Dumas Date: Fri, 25 Aug 2023 10:54:59 -0400 Subject: [PATCH] fixing a subtle bug in With() --- logger/wrappedslogger.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/logger/wrappedslogger.go b/logger/wrappedslogger.go index 4130b14..1500543 100644 --- a/logger/wrappedslogger.go +++ b/logger/wrappedslogger.go @@ -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}