From 58378e076484a80e60fd40521365d9b3bda3c4f6 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Mon, 4 Dec 2023 12:08:46 +0100 Subject: [PATCH] log: remove unused code --- log/handler.go | 66 -------------------------------------------------- 1 file changed, 66 deletions(-) diff --git a/log/handler.go b/log/handler.go index fcae61b4f8..ed4596efcd 100644 --- a/log/handler.go +++ b/log/handler.go @@ -2,14 +2,9 @@ package log import ( "context" - "fmt" "io" - "math/big" - "reflect" "sync" - "time" - "github.com/holiman/uint256" "golang.org/x/exp/slog" ) @@ -125,64 +120,3 @@ func JSONHandler(wr io.Writer) slog.Handler { func LogfmtHandler(wr io.Writer) slog.Handler { return slog.NewTextHandler(wr, nil) } - -// LogfmtHandlerWithLevel returns the same handler as LogfmtHandler but it only outputs -// records which are less than or equal to the specified verbosity level. -func LogfmtHandlerWithLevel(wr io.Writer, level slog.Level) slog.Handler { - return slog.NewTextHandler(wr, &slog.HandlerOptions{ - ReplaceAttr: builtinReplaceLogfmt, - Level: &leveler{level}, - }) -} - -func builtinReplaceLogfmt(_ []string, attr slog.Attr) slog.Attr { - return builtinReplace(nil, attr, true) -} - -func builtinReplaceJSON(_ []string, attr slog.Attr) slog.Attr { - return builtinReplace(nil, attr, false) -} - -func builtinReplace(_ []string, attr slog.Attr, logfmt bool) slog.Attr { - switch attr.Key { - case slog.TimeKey: - if attr.Value.Kind() == slog.KindTime { - if logfmt { - return slog.String("t", attr.Value.Time().Format(timeFormat)) - } else { - return slog.Attr{Key: "t", Value: attr.Value} - } - } - case slog.LevelKey: - if l, ok := attr.Value.Any().(slog.Level); ok { - attr = slog.Any("lvl", LevelString(l)) - return attr - } - } - - switch v := attr.Value.Any().(type) { - case time.Time: - if logfmt { - attr = slog.String(attr.Key, v.Format(timeFormat)) - } - case *big.Int: - if v == nil { - attr.Value = slog.StringValue("") - } else { - attr.Value = slog.StringValue(v.String()) - } - case *uint256.Int: - if v == nil { - attr.Value = slog.StringValue("") - } else { - attr.Value = slog.StringValue(v.Dec()) - } - case fmt.Stringer: - if v == nil || (reflect.ValueOf(v).Kind() == reflect.Pointer && reflect.ValueOf(v).IsNil()) { - attr.Value = slog.StringValue("") - } else { - attr.Value = slog.StringValue(v.String()) - } - } - return attr -}