deferlog provide a useful toolset for rs/zerolog.
- use console logger while running in a terminal
- use json logger while log into file (such as running in container)
- read the environement
LOG_LEVEL
to change default log level
func example() (err error) {
start := time.Now()
defer func() {
deferlog.DebugWarn(err).
Dur("took", time.Since(start)).
Msg("run the example function")
}()
// do something here
return nil
}