mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-27 03:58:55 +08:00
zap
This commit is contained in:
parent
9445f74e1a
commit
5f0346be77
@ -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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user