From f3ec6346e01965833ed944886114b9a5f267ab4b Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Fri, 9 Jun 2023 14:32:37 +0800 Subject: [PATCH] update zap --- pkg/common/db/controller/msg.go | 2 +- pkg/common/log/zap.go | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/common/db/controller/msg.go b/pkg/common/db/controller/msg.go index 5c9f4b570..1cb046125 100644 --- a/pkg/common/db/controller/msg.go +++ b/pkg/common/db/controller/msg.go @@ -519,7 +519,7 @@ func (db *commonMsgDatabase) GetMsgBySeqsRange(ctx context.Context, userID strin } log.ZDebug(ctx, "get msgs from cache", "successMsgs", successMsgs) if len(failedSeqs) != 0 { - log.ZDebug(ctx, "msgs not exist in redis", err, "seqs", failedSeqs) + log.ZDebug(ctx, "msgs not exist in redis", "seqs", failedSeqs) } // get from cache or db prome.Add(prome.MsgPullFromRedisSuccessCounter, len(successMsgs)) diff --git a/pkg/common/log/zap.go b/pkg/common/log/zap.go index 407fc8f12..389ebc4e8 100644 --- a/pkg/common/log/zap.go +++ b/pkg/common/log/zap.go @@ -2,7 +2,6 @@ package log import ( "context" - "errors" "fmt" "os" "path/filepath" @@ -119,14 +118,14 @@ func (l *ZapLogger) cores(isStdout bool, isJson bool, logLocation string, rotate return nil, err } var cores []zapcore.Core + // if logLocation == "" && !isStdout { + // return nil, errors.New("log storage location is empty and not stdout") + // } if logLocation != "" { cores = []zapcore.Core{ zapcore.NewCore(fileEncoder, writer, zap.NewAtomicLevelAt(l.level)), } } - if logLocation == "" && !isStdout { - return nil, errors.New("log storage location is empty and not stdout") - } if isStdout { cores = append(cores, zapcore.NewCore(fileEncoder, zapcore.Lock(os.Stdout), zap.NewAtomicLevelAt(l.level))) // cores = append(cores, zapcore.NewCore(fileEncoder, zapcore.Lock(os.Stderr), zap.NewAtomicLevelAt(l.level)))