diff --git a/log/format.go b/log/format.go index 3d6e3029ed..057bbc32c1 100644 --- a/log/format.go +++ b/log/format.go @@ -73,7 +73,7 @@ type TerminalStringer interface { // Example: // // [DBUG] [May 16 20:58:45] remove route ns=haproxy addr=127.0.0.1:50002 -func TerminalFormat(r slog.Record, usecolor bool) []byte { +func TerminalFormat(r slog.Record, commonAttrs []slog.Attr, usecolor bool) []byte { msg := escapeMessage(r.Message) var color = 0 if usecolor { @@ -106,7 +106,7 @@ func TerminalFormat(r slog.Record, usecolor bool) []byte { b.Write(bytes.Repeat([]byte{' '}, termMsgJust-length)) } // print the keys logfmt style - logfmt(b, []slog.Attr{}, r, color, true) + logfmt(b, commonAttrs, r, color, true) return b.Bytes() } diff --git a/log/handler.go b/log/handler.go index f43df0392b..4922366e43 100644 --- a/log/handler.go +++ b/log/handler.go @@ -140,8 +140,7 @@ func TerminalHandlerWithLevel(wr io.Writer, lvl slog.Level, useColor bool) slog. func (h *terminalHandler) Handle(_ context.Context, r slog.Record) error { h.mu.Lock() defer h.mu.Unlock() - r.AddAttrs(h.attrs...) - h.wr.Write(TerminalFormat(r, h.useColor)) + h.wr.Write(TerminalFormat(r, h.attrs, h.useColor)) return nil } diff --git a/log/logger_test.go b/log/logger_test.go index bdf4a51eb4..1b50e96110 100644 --- a/log/logger_test.go +++ b/log/logger_test.go @@ -5,7 +5,6 @@ import ( "os" "strings" "testing" - "golang.org/x/exp/slog" )