mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
caller
This commit is contained in:
parent
bde01538a0
commit
ede2097678
@ -64,7 +64,7 @@ func NewZapLogger(logLevel int, isStdout bool, isJson bool, logLocation string,
|
|||||||
zapConfig := zap.Config{
|
zapConfig := zap.Config{
|
||||||
Level: zap.NewAtomicLevelAt(logLevelMap[logLevel]),
|
Level: zap.NewAtomicLevelAt(logLevelMap[logLevel]),
|
||||||
EncoderConfig: zap.NewProductionEncoderConfig(),
|
EncoderConfig: zap.NewProductionEncoderConfig(),
|
||||||
InitialFields: map[string]interface{}{"PID": os.Getegid()},
|
// InitialFields: map[string]interface{}{"PID": os.Getegid()},
|
||||||
DisableStacktrace: true,
|
DisableStacktrace: true,
|
||||||
}
|
}
|
||||||
if isJson {
|
if isJson {
|
||||||
@ -103,9 +103,13 @@ func (l *ZapLogger) cores(logLevel int, isStdout bool, isJson bool, logLocation
|
|||||||
} else {
|
} else {
|
||||||
c.EncodeLevel = zapcore.CapitalColorLevelEncoder
|
c.EncodeLevel = zapcore.CapitalColorLevelEncoder
|
||||||
fileEncoder = zapcore.NewConsoleEncoder(c)
|
fileEncoder = zapcore.NewConsoleEncoder(c)
|
||||||
|
customCallerEncoder := func(caller zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder) {
|
||||||
|
// enc.AppendString("[" + l.traceId + "]")
|
||||||
|
enc.AppendString("[" + caller.TrimmedPath() + "]")
|
||||||
|
}
|
||||||
|
c.EncodeCaller = customCallerEncoder
|
||||||
}
|
}
|
||||||
fileEncoder.AddInt("PID", os.Getpid())
|
fileEncoder.AddInt("PID", os.Getpid())
|
||||||
fileEncoder.AddString("operationID", "")
|
|
||||||
writer, err := l.getWriter(logLocation, rotateCount)
|
writer, err := l.getWriter(logLocation, rotateCount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user