express built-in time key as String attribute instead of Any

This commit is contained in:
Jared Wasinger 2023-11-14 21:57:33 +08:00
parent 655e6fc1fd
commit d960dc8fa7

View file

@ -177,7 +177,7 @@ func builtinReplace(_ []string, attr slog.Attr) slog.Attr {
switch attr.Key { switch attr.Key {
case slog.TimeKey: case slog.TimeKey:
if attr.Value.Kind() == slog.KindTime { if attr.Value.Kind() == slog.KindTime {
return slog.Any("t", attr.Value.Time().Format(timeFormat)) return slog.String("t", attr.Value.Time().Format(timeFormat))
} }
case slog.LevelKey: case slog.LevelKey:
if l, ok := attr.Value.Any().(slog.Level); ok { if l, ok := attr.Value.Any().(slog.Level); ok {