Skip to content

Commit

Permalink
embed: only log stream error with debug level (etcd-io#13656)
Browse files Browse the repository at this point in the history
Co-authored-by: tangcong <tangcong506@gmail.com>
  • Loading branch information
2 people authored and tjungblu committed Sep 8, 2022
1 parent 580617a commit 14e96ed
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 14e96ed

Please sign in to comment.