This commit is contained in:
wangchuxiao 2023-04-17 21:18:11 +08:00
parent 9445f74e1a
commit 5f0346be77

View File

@ -92,7 +92,7 @@ func NewZapLogger(logLevel int, isStdout bool, isJson bool, logLocation string,
func (l *ZapLogger) cores(logLevel int, isStdout bool, isJson bool, logLocation string, rotateCount uint) (zap.Option, error) { func (l *ZapLogger) cores(logLevel int, isStdout bool, isJson bool, logLocation string, rotateCount uint) (zap.Option, error) {
c := zap.NewProductionEncoderConfig() c := zap.NewProductionEncoderConfig()
c.EncodeTime = zapcore.ISO8601TimeEncoder c.EncodeTime = zapcore.RFC3339TimeEncoder
c.EncodeDuration = zapcore.SecondsDurationEncoder c.EncodeDuration = zapcore.SecondsDurationEncoder
c.MessageKey = "msg" c.MessageKey = "msg"
c.LevelKey = "level" c.LevelKey = "level"
@ -148,9 +148,13 @@ func (l *ZapLogger) getWriter(logLocation string, rorateCount uint) (zapcore.Wri
} }
func (l *ZapLogger) CapitalColorLevelEncoder(level zapcore.Level, enc zapcore.PrimitiveArrayEncoder) { func (l *ZapLogger) CapitalColorLevelEncoder(level zapcore.Level, enc zapcore.PrimitiveArrayEncoder) {
zapcore.CapitalColorLevelEncoder(level, enc) ls, ok := _levelToCapitalColorString[level]
enc.AppendString(l.callerKey) if !ok {
enc.AppendString(l.loggerKey) ls = _levelToCapitalColorString[zapcore.ErrorLevel]
}
for _, s := range ls {
enc.AppendString(s)
}
} }
func (l *ZapLogger) ToZap() *zap.SugaredLogger { func (l *ZapLogger) ToZap() *zap.SugaredLogger {