-
Notifications
You must be signed in to change notification settings - Fork 63
Panic on nil *time.Time value #85
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
func main() {
jsonLog := slog.New(slog.NewJSONHandler(os.Stdout, nil))
textLog := slog.New(slog.NewTextHandler(os.Stdout, nil))
tintLog := slog.New(tint.NewHandler(os.Stdout, nil))
var t *time.Time
jsonLog.Info("Hello", "t", t) // Fine.
textLog.Info("Hello", "t", t) // Fine.
tintLog.Info("Hello", "t", t) // panic: value method time.Time.MarshalText called using nil *Time pointer
}
https://go.dev/play/p/UAi6SlyJJnQ
This makes tint not a drop-in alternative for the common slog handlers. My understanding is that slog handles this case as follows: https://github.com/golang/go/blob/master/src/log/slog/handler.go#L558
Thanks for tint. A bit of colour in our dull backend world is nice.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working