diff --git a/cmd/sandbox-api/main.go b/cmd/sandbox-api/main.go index b2c63f77..1ddd51ca 100644 --- a/cmd/sandbox-api/main.go +++ b/cmd/sandbox-api/main.go @@ -187,7 +187,6 @@ func main() { "/ping", }, QuietDownPeriod: 10 * time.Second, - TimeFieldName: "time", // SourceFieldName: "source", }) diff --git a/internal/log/log.go b/internal/log/log.go index 27b76658..11deddec 100644 --- a/internal/log/log.go +++ b/internal/log/log.go @@ -26,14 +26,22 @@ var Logger *slog.Logger func InitLoggers(debugFlag bool, attrs []slog.Attr) { Err = log.New(os.Stderr, "!!! ", log.LstdFlags) Out = log.New(os.Stdout, " ", log.LstdFlags) + + replaceAttrs := func(groups []string, a slog.Attr) slog.Attr { + switch a.Key { + case slog.TimeKey: + a.Key = "timestamp" + } + return a + } + opts := slog.HandlerOptions{ Level: slog.LevelInfo, + ReplaceAttr: replaceAttrs, } if debugFlag { Debug = log.New(os.Stdout, "(d) ", log.LstdFlags) - opts = slog.HandlerOptions{ - Level: slog.LevelDebug, - } + opts.Level = slog.LevelDebug } else { Debug = log.New(io.Discard, "(d) ", log.LstdFlags) }