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