From d6857f4b249edf981c48fa3c9e49899fbdfdc9b9 Mon Sep 17 00:00:00 2001 From: Bingyi Sun Date: Mon, 28 Feb 2022 17:23:54 +0800 Subject: [PATCH] Remove globalZapWrapper in logutil.go (#15726) issue: #15720 Signed-off-by: sunby Co-authored-by: sunby --- internal/util/logutil/logutil.go | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/internal/util/logutil/logutil.go b/internal/util/logutil/logutil.go index 0a22c630b6..1edfa4076f 100644 --- a/internal/util/logutil/logutil.go +++ b/internal/util/logutil/logutil.go @@ -19,7 +19,6 @@ package logutil import ( "context" "sync" - "sync/atomic" "github.com/milvus-io/milvus/internal/log" @@ -105,17 +104,6 @@ func LogPanic() { } var once sync.Once -var _globalZapWrapper atomic.Value - -const defaultLogLevel = "info" - -func init() { - conf := &log.Config{Level: defaultLogLevel, File: log.FileLogConfig{}} - lg, _, _ := log.InitLogger(conf) - _globalZapWrapper.Store(&zapWrapper{ - logger: lg, - }) -} // SetupLogger is used to initialize the log with config. func SetupLogger(cfg *log.Config) { @@ -129,24 +117,11 @@ func SetupLogger(cfg *log.Config) { } // initialize grpc and etcd logger - c := *cfg - c.Level = defaultLogLevel - lg, _, err := log.InitLogger(&c) - if err != nil { - log.Fatal("initialize grpc/etcd logger error", zap.Error(err)) - } - - wrapper := &zapWrapper{lg} + wrapper := &zapWrapper{logger} grpclog.SetLoggerV2(wrapper) - _globalZapWrapper.Store(wrapper) }) } -// GetZapWrapper returns the stored zapWrapper object. -func GetZapWrapper() *zapWrapper { - return _globalZapWrapper.Load().(*zapWrapper) -} - type logKey int const logCtxKey logKey = iota