-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
*: make log level configurable #10947
Conversation
Codecov Report
@@ Coverage Diff @@
## master #10947 +/- ##
==========================================
+ Coverage 63.6% 63.74% +0.14%
==========================================
Files 400 401 +1
Lines 37415 37470 +55
==========================================
+ Hits 23796 23885 +89
+ Misses 12001 11945 -56
- Partials 1618 1640 +22
Continue to review full report at Codecov.
|
if cfg.Debug { | ||
fmt.Fprintf(os.Stderr, "[WARNING] Deprecated '--debug' flag is set to %v (use '--log-level=debug' instead\n", cfg.Debug) | ||
} | ||
if cfg.Debug && cfg.LogLevel != "debug" { |
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.
Should this just be a warning? This setting is actually conflicting with itself.
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.
Could you clarify? This is a warning when something like etcd --debug --log-level warning
is configured. With this change, the log level will be overwritten by --log-level warning
.
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.
I see. So --log-level
, when provided, will overwrite --debug
.
|
||
|
||
TO BE DEPRECATED: | ||
|
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.
nit: remove the first empty line?
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.
Fixed.
@jingyih PTAL. Thx. |
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.
Looks good. Added one more question.
if cfg.Debug { | ||
fmt.Fprintf(os.Stderr, "[WARNING] Deprecated '--debug' flag is set to %v (use '--log-level=debug' instead\n", cfg.Debug) | ||
} | ||
if cfg.Debug && cfg.LogLevel != "debug" { |
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.
I see. So --log-level
, when provided, will overwrite --debug
.
if cfg.Debug { | ||
copied.Level = zap.NewAtomicLevelAt(zap.DebugLevel) | ||
copied.Level = zap.NewAtomicLevelAt(logutil.ConvertToZapLevel(cfg.LogLevel)) | ||
if cfg.Debug || cfg.LogLevel == "debug" { |
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.
If LogLevel
is not "debug", it should overwrite Debug
flag here?
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.
Debug
is only used here, so no need overwrite :)
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.
So under configuration etcd --debug --log-level info
, grpc tracking is enabled?
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.
etcd --debug --log-level info, grpc tracking is enabled?
Yes, because cfg.Debug
will evaluate to true.
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.
Sorry I think I am still confused. As an example, etcd --debug --log-level info
sets the logging level to "info", but grpc tracking is enabled. This seems to be different than the previous behavior, where tracing is only enabled if logging level is set to "debug"?
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.
As an example, etcd --debug --log-level info sets the logging level to "info", but grpc tracking is enabled. This seems to be different than the previous behavior,
I clarified with comments in the code.
Basically, we want to keep the backward compatibility since --log-level
is the new flag in v3.4. For instance, etcd --debug --log-level warning
in v3.4 should work in the same way as etcd --debug
in v3.3, thus enabling the gRPC tracing even when --log-level warning
was meant to disable gRPC tracing. If --debug
is passed with non-debug --log-level
, the user will be warned about its inconsistent log configuration in v3.4.
Let me know.
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.
Oh I misread earlier. Thanks!
Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
Make log level configurable, and deprecate "debug" flag in v3.5. And adds more warnings on flags that's being deprecated in v3.5. Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
To make it consistent Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
LGTM |
Address #10946.
/cc @jingyih @benitogf
In 3.5, we can deprecate
--debug
flag, in favor of--log-level=debug
.Will update CHANGELOG in a separate PR.