mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-24 02:16:16 +08:00
zap
This commit is contained in:
parent
22633cbe77
commit
3202b6869d
@ -65,7 +65,7 @@ type ZapLogger struct {
|
|||||||
func NewZapLogger(logLevel int, isStdout bool, isJson bool, logLocation string, rotateCount uint) (*ZapLogger, error) {
|
func NewZapLogger(logLevel int, isStdout bool, isJson bool, logLocation string, rotateCount uint) (*ZapLogger, error) {
|
||||||
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,
|
||||||
}
|
}
|
||||||
@ -109,7 +109,8 @@ func (l *ZapLogger) cores(logLevel int, isStdout bool, isJson bool, logLocation
|
|||||||
} else {
|
} else {
|
||||||
c.EncodeLevel = l.CapitalColorLevelEncoder
|
c.EncodeLevel = l.CapitalColorLevelEncoder
|
||||||
customCallerEncoder := func(caller zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder) {
|
customCallerEncoder := func(caller zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder) {
|
||||||
enc.AppendString("[" + caller.TrimmedPath() + "]")
|
s := "[" + caller.TrimmedPath() + "]"
|
||||||
|
enc.AppendString(_levelToColor[l.zap.Level()].Add(s))
|
||||||
}
|
}
|
||||||
c.EncodeCaller = customCallerEncoder
|
c.EncodeCaller = customCallerEncoder
|
||||||
fileEncoder = zapcore.NewConsoleEncoder(c)
|
fileEncoder = zapcore.NewConsoleEncoder(c)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user