Closed tmm1 closed 1 year ago
You could use SetPrefix()
on the sub-logger.
sub := log.With()
sub.SetPrefix("myapp")
...
sub.Info("hello world")
Yep that works, thanks!
I would still like to see a convenience wrapper to make it a one liner..
log.WithPrefix("myapp").Info("hello world")
I would like to be able to set some options on the default logger (like timestamp format, loglevel), then create sub-loggers which inherit those settings but have their own prefixes.
Right now it seems the only way to create a sub-logger is
With()
which adds key/value pairs but in my case I don't have key/value pairs to add I just want a new prefix.WDYT about adding a new
WithPrefix()
?