|
|
|
@ -102,10 +102,10 @@ func (l *ZapLogger) cores(logLevel int, isStdout bool, isJson bool, logLocation
|
|
|
|
|
fileEncoder = zapcore.NewJSONEncoder(c)
|
|
|
|
|
} else {
|
|
|
|
|
c.EncodeLevel = zapcore.CapitalColorLevelEncoder
|
|
|
|
|
c.EncodeCaller = customCallerEncoder
|
|
|
|
|
fileEncoder = zapcore.NewConsoleEncoder(c)
|
|
|
|
|
}
|
|
|
|
|
fileEncoder.AddInt("PID", os.Getpid())
|
|
|
|
|
fileEncoder.AddString("operationID", "")
|
|
|
|
|
writer, err := l.getWriter(logLocation, rotateCount)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
@ -127,14 +127,6 @@ func (l *ZapLogger) cores(logLevel int, isStdout bool, isJson bool, logLocation
|
|
|
|
|
}), nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func customCallerEncoder(caller zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder) {
|
|
|
|
|
enc.AppendString("\x1b[32m")
|
|
|
|
|
enc.AppendString(caller.Function)
|
|
|
|
|
enc.AppendString(":")
|
|
|
|
|
enc.AppendInt(caller.Line)
|
|
|
|
|
enc.AppendString("\x1b[0m")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (l *ZapLogger) getWriter(logLocation string, rorateCount uint) (zapcore.WriteSyncer, error) {
|
|
|
|
|
logf, err := rotatelogs.New(logLocation+sp+"OpenIM.log.all"+".%Y-%m-%d",
|
|
|
|
|
rotatelogs.WithRotationCount(rorateCount),
|
|
|
|
|