From fe93d91894a049960bb4f981d92e958dc70a5013 Mon Sep 17 00:00:00 2001 From: Pavel Sviderski Date: Wed, 30 Apr 2025 16:56:32 +1000 Subject: [PATCH] fix: attributes handling in SlogTextHandler for child loggers --- internal/log/handler.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/log/handler.go b/internal/log/handler.go index bd633c40..6452c62d 100644 --- a/internal/log/handler.go +++ b/internal/log/handler.go @@ -45,11 +45,19 @@ func (h *SlogTextHandler) Enabled(ctx context.Context, level slog.Level) bool { } func (h *SlogTextHandler) WithAttrs(attrs []slog.Attr) slog.Handler { - return h.TextHandler.WithAttrs(attrs) + return &SlogTextHandler{ + TextHandler: h.TextHandler.WithAttrs(attrs).(*slog.TextHandler), + opts: h.opts, + w: h.w, + } } func (h *SlogTextHandler) WithGroup(name string) slog.Handler { - return h.TextHandler.WithGroup(name) + return &SlogTextHandler{ + TextHandler: h.TextHandler.WithGroup(name).(*slog.TextHandler), + opts: h.opts, + w: h.w, + } } func (h *SlogTextHandler) Handle(ctx context.Context, r slog.Record) error {