Open rwngallego opened 3 years ago
Hey, not sure I understand your problem with SetGlobalLevel
.
Do you want lecho
to compare levels of a given instance and global value before matching it?
Yes, in case the log instance has TraceLevel
(which maps to log.OFF
in lecho), check if maybe the library user has set the global level, because that is another way to set the log level in Zerolog: you can either set it per log instance (you already cover this) or globally with SetGlobalLevel
(not supported yet).
Another alternative is to initially use what we have set using SetGlobalLevel
and override it with whatever the log instance has that is different to TraceLevel
, or the other way around.
From the zerolog documentation:
I've found a problem where the echo middleware didn't log requests using an existing zerolog instance because by default the level set in
log
isTraceLevel
here https://github.com/rs/zerolog/blob/master/log.go#L213 which maps tozerolog.NoLevel
orlog.OFF
inlecho
. However, in zerolog we usually use theSetGlobalLevel
to set the log level. One way would be to consider thezerolog.Level
value when calculating the log level https://github.com/ziflex/lecho/blob/master/options.go#L19: