Skip to content
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

Merged
merged 7 commits into from
Jul 29, 2019
Merged

*: make log level configurable #10947

merged 7 commits into from
Jul 29, 2019

Conversation

gyuho
Copy link
Contributor

@gyuho gyuho commented Jul 29, 2019

Address #10946.

/cc @jingyih @benitogf

etcd --logger zap --log-level warn
{"level":"warn","ts":"2019-07-28T21:50:24.137-0500","caller":"etcdmain/etcd.go:119","msg":"'data-dir' was empty; using default","data-dir":"default.etcd"}
{"level":"warn","ts":"2019-07-28T21:50:24.242-0500","caller":"auth/store.go:1317","msg":"simple token is not cryptographically signed"}
{"level":"warn","ts":"2019-07-28T21:50:24.269-0500","caller":"etcdserver/metrics.go:186","msg":"failed to get file descriptor usage","error":"cannot get FDUsage on darwin"}

^C{"level":"warn","ts":"2019-07-28T21:50:32.216-0500","caller":"grpclog/grpclog.go:60","msg":"transport: http2Server.HandleStreams failed to read frame: read tcp 127.0.0.1:2379->127.0.0.1:52750: use of closed network connection"}

In 3.5, we can deprecate --debug flag, in favor of --log-level=debug.

Will update CHANGELOG in a separate PR.

@codecov-io
Copy link

codecov-io commented Jul 29, 2019

Codecov Report

Merging #10947 into master will increase coverage by 0.14%.
The diff coverage is 45.45%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
pkg/logutil/zap.go 78.57% <ø> (ø) ⬆️
pkg/logutil/zap_raft.go 50% <100%> (+2.94%) ⬆️
raft/logger.go 50% <100%> (+4.28%) ⬆️
embed/config.go 50.84% <100%> (+0.13%) ⬆️
etcdmain/config.go 82.95% <100%> (+0.07%) ⬆️
pkg/logutil/log_level.go 22.22% <22.22%> (ø)
embed/config_logging.go 27.62% <36.84%> (+0.61%) ⬆️
etcdserver/raft.go 77.83% <80%> (+0.26%) ⬆️
client/keys.go 60.3% <0%> (-31.16%) ⬇️
etcdserver/api/v3rpc/util.go 51.61% <0%> (-16.13%) ⬇️
... and 26 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 936c506...a900ef5. Read the comment docs.

@gyuho gyuho requested a review from jingyih July 29, 2019 16:58
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" {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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:

Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@gyuho
Copy link
Contributor Author

gyuho commented Jul 29, 2019

@jingyih PTAL. Thx.

Copy link
Contributor

@jingyih jingyih left a 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" {
Copy link
Contributor

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" {
Copy link
Contributor

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?

Copy link
Contributor Author

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 :)

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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"?

Copy link
Contributor Author

@gyuho gyuho Jul 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jingyih

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.

Copy link
Contributor

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>
@jingyih
Copy link
Contributor

jingyih commented Jul 29, 2019

LGTM

@gyuho gyuho merged commit 6e766ac into etcd-io:master Jul 29, 2019
@gyuho gyuho deleted the log-level branch July 29, 2019 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants