It seems that in practice it behaves almost the same. zerolog.Logger{} does more work though, constructing whole event and then bailing out when it tries to write to nil. I think it would be nice if zerolog.Logger{} would behave exactly the same as zerolog.Nop. I think that Logger.should should probably check if writer is set to non-nil value. Currently it is:
Zero logger returns false on l.w == nil while nop logger return false on lvl < l.level (because l.level is set to Disabled which holds true for all levels).
It seems that in practice it behaves almost the same.
zerolog.Logger{}
does more work though, constructing whole event and then bailing out when it tries to write tonil
. I think it would be nice ifzerolog.Logger{}
would behave exactly the same aszerolog.Nop
. I think thatLogger.should
should probably check if writer is set to non-nil value. Currently it is:I propose:
Zero logger returns
false
onl.w == nil
while nop logger returnfalse
onlvl < l.level
(becausel.level
is set toDisabled
which holds true for all levels).