This is a beginner question, sorry if it is obvious but there are elements of Go that I still struggle with.
I use (and love!) zerolog in all my backend code, by importing github.com/rs/zerolog/log and then log.Info().Msg("thank you"). It works great to create structured (JSON) logs.
I am now developing a cli and these logs are less useful because they will be read by humans. The README suggests
I want to customize further, though and the resolution I just below in the README.
My problem: up to then, I was modifying the log handler which was fine because I could do that for instance in an init() routine. With further customization, I went for
zerolog.ConsoleWriter includes the timestamp as default
so use PartsExclude to remove the timestamp:
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr, PartsExclude: []string{"time"}})
This is a beginner question, sorry if it is obvious but there are elements of Go that I still struggle with.
I use (and love!)
zerolog
in all my backend code, by importinggithub.com/rs/zerolog/log
and thenlog.Info().Msg("thank you")
. It works great to create structured (JSON) logs.I am now developing a cli and these logs are less useful because they will be read by humans. The README suggests
This is great - the output is much better.
I want to customize further, though and the resolution I just below in the README.
My problem: up to then, I was modifying the
log
handler which was fine because I could do that for instance in aninit()
routine. With further customization, I went forThis gives the output
So despite not using
.With().Timestamp()
, the timestamp still wants to be there. How to completely switch it off?