feat(log): update zap interface (#2620)

pull/2657/head
aveyuan 2 years ago committed by GitHub
parent 77abb6356f
commit 7def38acde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      contrib/log/zap/zap.go

@ -19,13 +19,14 @@ func NewLogger(zlog *zap.Logger) *Logger {
}
func (l *Logger) Log(level log.Level, keyvals ...interface{}) error {
if len(keyvals) == 0 || len(keyvals)%2 != 0 {
keylen := len(keyvals)
if keylen == 0 || keylen%2 != 0 {
l.log.Warn(fmt.Sprint("Keyvalues must appear in pairs: ", keyvals))
return nil
}
var data []zap.Field
for i := 0; i < len(keyvals); i += 2 {
var data []zap.Field = make([]zap.Field, 0, (keylen/2)+1)
for i := 0; i < keylen; i += 2 {
data = append(data, zap.Any(fmt.Sprint(keyvals[i]), keyvals[i+1]))
}

Loading…
Cancel
Save