Skip to content

Commit

Permalink
feat(contrib/log/zap): If disable this level of logging entirely, avo…
Browse files Browse the repository at this point in the history
…id additional overhead

  * goimports

* gofmt
  • Loading branch information
harbourlga committed Jul 3, 2024
1 parent 3198e0b commit 982b998
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions contrib/log/zap/zap.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package zap
import (
"fmt"

"go.uber.org/zap"

"github.com/go-kratos/kratos/v2/log"

"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)

var _ log.Logger = (*Logger)(nil)
Expand All @@ -32,6 +33,11 @@ func NewLogger(zlog *zap.Logger) *Logger {
}

func (l *Logger) Log(level log.Level, keyvals ...interface{}) error {
// If logging at this level is completely disabled, skip the overhead of
// string formatting.
if zapcore.Level(level) < zapcore.DPanicLevel && !l.log.Core().Enabled(zapcore.Level(level)) {
return nil
}
var (
msg = ""
keylen = len(keyvals)
Expand Down

0 comments on commit 982b998

Please sign in to comment.