adds timestamp disable

This commit is contained in:
Hyatt 2025-02-22 21:49:14 -06:00
parent c97d51c48f
commit c1db6edf39
Signed by: nhyatt
GPG Key ID: C50D0BBB5BC40BEA

View File

@ -34,6 +34,9 @@ func Init(writer string) {
ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr { ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr {
if a.Key == slog.TimeKey { if a.Key == slog.TimeKey {
a.Value = slog.StringValue(a.Value.Time().Format(time.DateTime)) a.Value = slog.StringValue(a.Value.Time().Format(time.DateTime))
// To disable the timestamp all together, return an empty value.
// return slog.Attr{}
} }
if a.Key == slog.LevelKey { if a.Key == slog.LevelKey {
level := a.Value.Any().(slog.Level) level := a.Value.Any().(slog.Level)
@ -44,6 +47,7 @@ func Init(writer string) {
a.Value = slog.StringValue(levelLabel) a.Value = slog.StringValue(levelLabel)
} }
return a return a
}, },
} }