From bf20ac04785a3b9acf50f9ae1b220ace4591084f Mon Sep 17 00:00:00 2001 From: Travis Bischel Date: Wed, 8 Mar 2023 10:15:34 -0700 Subject: [PATCH] plugin/kzap: support LogLevelNone 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. --- plugin/kzap/kzap.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugin/kzap/kzap.go b/plugin/kzap/kzap.go index dea6ec0b..90fcd9e1 100644 --- a/plugin/kzap/kzap.go +++ b/plugin/kzap/kzap.go @@ -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 { @@ -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 }) }