mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
zap
This commit is contained in:
parent
3fa96b0700
commit
bde01538a0
@ -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),
|
||||
|
Loading…
x
Reference in New Issue
Block a user