refactored logger wrapper

This commit is contained in:
Evgeniy Kulikov 2020-02-29 18:00:20 +03:00
parent 5a640fc0fa
commit dba58f3935
No known key found for this signature in database
GPG key ID: BF6AEE0A2A699BF2

View file

@ -11,7 +11,8 @@ import (
)
type zapLogger struct {
log *zap.Logger
zapcore.Core
log *zap.SugaredLogger
}
const (
@ -23,10 +24,12 @@ const (
)
func gRPCLogger(l *zap.Logger) grpclog.LoggerV2 {
return &zapLogger{
log: l.WithOptions(
log := l.WithOptions(
// skip gRPCLog + zapLogger in caller
zap.AddCallerSkip(2)),
zap.AddCallerSkip(2))
return &zapLogger{
Core: log.Core(),
log: log.Sugar(),
}
}
@ -102,60 +105,32 @@ func newLogger(v *viper.Viper) *zap.Logger {
zap.String("app_version", version))
}
func (z *zapLogger) Info(args ...interface{}) {
z.log.Sugar().Info(args...)
}
func (z *zapLogger) Info(args ...interface{}) { z.log.Info(args...) }
func (z *zapLogger) Infoln(args ...interface{}) {
z.log.Sugar().Info(args...)
}
func (z *zapLogger) Infoln(args ...interface{}) { z.log.Info(args...) }
func (z *zapLogger) Infof(format string, args ...interface{}) {
z.log.Sugar().Infof(format, args...)
}
func (z *zapLogger) Infof(format string, args ...interface{}) { z.log.Infof(format, args...) }
func (z *zapLogger) Println(args ...interface{}) {
z.log.Sugar().Info(args...)
}
func (z *zapLogger) Println(args ...interface{}) { z.log.Info(args...) }
func (z *zapLogger) Printf(format string, args ...interface{}) {
z.log.Sugar().Infof(format, args...)
}
func (z *zapLogger) Printf(format string, args ...interface{}) { z.log.Infof(format, args...) }
func (z *zapLogger) Warning(args ...interface{}) {
z.log.Sugar().Warn(args...)
}
func (z *zapLogger) Warning(args ...interface{}) { z.log.Warn(args...) }
func (z *zapLogger) Warningln(args ...interface{}) {
z.log.Sugar().Warn(args...)
}
func (z *zapLogger) Warningln(args ...interface{}) { z.log.Warn(args...) }
func (z *zapLogger) Warningf(format string, args ...interface{}) {
z.log.Sugar().Warnf(format, args...)
}
func (z *zapLogger) Warningf(format string, args ...interface{}) { z.log.Warnf(format, args...) }
func (z *zapLogger) Error(args ...interface{}) {
z.log.Sugar().Error(args...)
}
func (z *zapLogger) Error(args ...interface{}) { z.log.Error(args...) }
func (z *zapLogger) Errorln(args ...interface{}) {
z.log.Sugar().Error(args...)
}
func (z *zapLogger) Errorln(args ...interface{}) { z.log.Error(args...) }
func (z *zapLogger) Errorf(format string, args ...interface{}) {
z.log.Sugar().Errorf(format, args...)
}
func (z *zapLogger) Errorf(format string, args ...interface{}) { z.log.Errorf(format, args...) }
func (z *zapLogger) Fatal(args ...interface{}) {
z.log.Sugar().Fatal(args...)
}
func (z *zapLogger) Fatal(args ...interface{}) { z.log.Fatal(args...) }
func (z *zapLogger) Fatalln(args ...interface{}) {
z.log.Sugar().Fatal(args...)
}
func (z *zapLogger) Fatalln(args ...interface{}) { z.log.Fatal(args...) }
func (z *zapLogger) Fatalf(format string, args ...interface{}) {
z.log.Sugar().Fatalf(format, args...)
}
func (z *zapLogger) Fatalf(format string, args ...interface{}) { z.Fatalf(format, args...) }
func (z *zapLogger) V(int) bool { return z.log.Core().Enabled(zapcore.DebugLevel) }
func (z *zapLogger) V(int) bool { return z.Enabled(zapcore.DebugLevel) }