-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
util/logutil: Remove useless grpc log in production #25454
Changes from 5 commits
c1cc79a
6c76acc
6062f29
7054a6a
af74b3d
66e4c6c
ac14a4e
fcf78d1
26a8776
ea31a51
19660f4
3f64c13
b95ee6c
d653e11
eea4682
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -42,8 +42,6 @@ const ( | |||
DefaultRecordPlanInSlowLog = 1 | ||||
// DefaultTiDBEnableSlowLog enables TiDB to log slow queries. | ||||
DefaultTiDBEnableSlowLog = true | ||||
// GRPCLogDebugVerbosity enables max verbosity when debugging grpc code. | ||||
GRPCLogDebugVerbosity = 99 | ||||
) | ||||
|
||||
// EmptyFileLogConfig is an empty FileLogConfig. | ||||
|
@@ -111,12 +109,33 @@ func InitLogger(cfg *LogConfig) error { | |||
return errors.Trace(err) | ||||
} | ||||
|
||||
// init logger for grpc debugging | ||||
err = initGRPCLogger(cfg) | ||||
if err != nil { | ||||
return errors.Trace(err) | ||||
} | ||||
|
||||
return nil | ||||
} | ||||
|
||||
func initGRPCLogger(cfg *LogConfig) error { | ||||
// copy Config struct by assignment | ||||
config := cfg.Config | ||||
// hack: force stdout | ||||
config.File.Filename = "" | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to force output grpc log to stdout? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The old logic directs all grpc log to std. Please take a look at Line 592 in 4f31cb4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch. Then there is a problem: the old logic output to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you find it hard to print to stderr then I think it is fine to print in the log file. There is no much difference from my perspective. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||||
if len(os.Getenv("GRPC_DEBUG")) > 0 { | ||||
// more information for verbosity: https://github.com/google/glog#verbose-logging | ||||
gzap.ReplaceGrpcLoggerV2WithVerbosity(gl, GRPCLogDebugVerbosity) | ||||
config.Level = "debug" | ||||
SabaPing marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
l, _, err := log.InitLogger(&cfg.Config, zap.AddStacktrace(zapcore.DebugLevel)) | ||||
if err != nil { | ||||
return errors.Trace(err) | ||||
} | ||||
gzap.ReplaceGrpcLoggerV2WithVerbosity(l, 999) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why change the value of verbosity? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line 593 in 4f31cb4
The original logic set the verbosity to 999. I just migrated the code and kept it unchanged. |
||||
} else { | ||||
gzap.ReplaceGrpcLoggerV2(gl) | ||||
config.Level = "error" | ||||
l, _, err := log.InitLogger(&cfg.Config, zap.AddStacktrace(zapcore.FatalLevel)) | ||||
if err != nil { | ||||
return errors.Trace(err) | ||||
} | ||||
gzap.ReplaceGrpcLoggerV2(l) | ||||
} | ||||
|
||||
return nil | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.