Skip to content

Commit

Permalink
embed: only log stream error with debug level (#13656)
Browse files Browse the repository at this point in the history
Co-authored-by: tangcong <tangcong506@gmail.com>
  • Loading branch information
kkkkun and tangcong authored Jan 30, 2022
1 parent 161bf7e commit a905430
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions embed/config_logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,14 @@ func (cfg *Config) setupLogging() error {
grpcLogOnce.Do(func() {
// debug true, enable info, warning, error
// debug false, only discard info
var gl grpclog.LoggerV2
gl, err = logutil.NewGRPCLoggerV2(copied)
if err == nil {
grpclog.SetLoggerV2(gl)
if cfg.LogLevel == "debug" {
var gl grpclog.LoggerV2
gl, err = logutil.NewGRPCLoggerV2(copied)
if err == nil {
grpclog.SetLoggerV2(gl)
}
} else {
grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, os.Stderr, os.Stderr))
}
})
return nil
Expand Down Expand Up @@ -245,7 +249,11 @@ func (cfg *Config) setupLogging() error {
c.loggerWriteSyncer = syncer

grpcLogOnce.Do(func() {
grpclog.SetLoggerV2(logutil.NewGRPCLoggerV2FromZapCore(cr, syncer))
if cfg.LogLevel == "debug" {
grpclog.SetLoggerV2(logutil.NewGRPCLoggerV2FromZapCore(cr, syncer))
} else {
grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, os.Stderr, os.Stderr))
}
})
return nil
}
Expand Down

0 comments on commit a905430

Please sign in to comment.