From dfa91fab926cfdd3c86a1d9cd59d1361d6165462 Mon Sep 17 00:00:00 2001 From: Adrian Sutton Date: Tue, 16 Apr 2024 08:33:45 +1000 Subject: [PATCH] cherry pick: https://github.com/ethereum-optimism/optimism/pull/10146 --- op-service/log/cli.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/op-service/log/cli.go b/op-service/log/cli.go index 966f7ad7d8c7..afac61483391 100644 --- a/op-service/log/cli.go +++ b/op-service/log/cli.go @@ -128,6 +128,7 @@ func FormatHandler(ft FormatType, color bool) func(io.Writer) slog.Handler { termColorHandler := func(w io.Writer) slog.Handler { return log.NewTerminalHandler(w, color) } + logfmtHandler := func(w io.Writer) slog.Handler { return log.LogfmtHandlerWithLevel(w, log.LevelTrace) } switch ft { case FormatJSON: return log.JSONHandler @@ -135,12 +136,12 @@ func FormatHandler(ft FormatType, color bool) func(io.Writer) slog.Handler { if term.IsTerminal(int(os.Stdout.Fd())) { return termColorHandler } else { - return log.LogfmtHandler + return logfmtHandler } case FormatTerminal: return termColorHandler case FormatLogFmt: - return log.LogfmtHandler + return logfmtHandler default: panic(fmt.Errorf("failed to create slog.Handler factory for format-type=%q and color=%v", ft, color)) }