Remove globalZapWrapper in logutil.go (#15726)

issue: #15720

Signed-off-by: sunby <bingyi.sun@zilliz.com>

Co-authored-by: sunby <bingyi.sun@zilliz.com>
pull/15649/head
Bingyi Sun 2022-02-28 17:23:54 +08:00 committed by GitHub
parent e1bfd14db1
commit d6857f4b24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 26 deletions

View File

@ -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