Skip to content

Commit

Permalink
plugin/kzap: support LogLevelNone
Browse files Browse the repository at this point in the history
Previously by default, it was not possible to opt into LogLevelNone for
the "level" call.

What this would mean is that if a person had no logging, we would could
call zap.Error and then their logger would just ignore the log. Now, we
avoid calling zap.Error at all.
  • Loading branch information
twmb committed Mar 8, 2023
1 parent 335cd47 commit bf20ac0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions plugin/kzap/kzap.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ func New(zl *zap.Logger, opts ...Opt) *Logger {
return kgo.LogLevelInfo
case c.Enabled(zap.WarnLevel):
return kgo.LogLevelWarn
case c.Enabled(zap.ErrorLevel):
return kgo.LogLevelError
}
return kgo.LogLevelError // default
return kgo.LogLevelNone // default
},
}
for _, opt := range opts {
Expand Down Expand Up @@ -79,8 +81,10 @@ func AtomicLevel(level zap.AtomicLevel) Opt {
return kgo.LogLevelInfo
case zap.WarnLevel:
return kgo.LogLevelWarn
case zap.ErrorLevel:
return kgo.LogLevelError
}
return kgo.LogLevelError
return kgo.LogLevelNone
})
}

Expand Down

0 comments on commit bf20ac0

Please sign in to comment.