Closed nhi-vanye closed 1 year ago
👍 Thanks for your feedback, I will add logger.ChannelName
option setting in next version.
var rootLogger = slog.NewWithName("root", func(l *slog.Logger) {
// l.ChannelName = "root"
// or
l.ChannelName = l.Name()
})
if not sets, will use
slog. DefaultChannelName
.
The time format can be sets by:
f := slog.AsTextFormatter(h1. Formatter())
f.TimeFormat = "2006-01-02 15:04:05.000"
Super-big thumbs up...
What is the best approach to tracking which "application subsystem" a message is coming from?
Normally I would create one logger per subsystem and configure its "name" or "channel".
But it seems that channel is only referenced in the record and its using the global
DefaultCannelName
in probe.go I have
where as in root.go I have
All of probe.go's messages are using
root
I have worked around it by using a subsystem specific template that hardcodes the name, but that seems unclean...