-
Notifications
You must be signed in to change notification settings - Fork 722
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
Show a warning when a subscriber subscribes to a log level that is disabled at compile time #975
Comments
I think having something like this definitely makes sense. The main question is where this functionality ought to go. I think it makes sense to implement something like this in the There are a couple tradeoffs with implementing this warning in
However, the biggest advantage of implementing this in
The alternative would be to implement this behavior in However, the downside of this is that we would need to move the static max level out of the Therefore, I think implementing this in |
As for how to report these errors: presently,
We could easily add this validation to the I think what we might want to do is consider tweaking these APIs so that we have a version that returns a We might also want to change the error type to store all the warnings in a |
This sounds really amazing :D thanks for thinking of this! Showing exactly the logging that will be ignored is extremely helpful.
From the rustc perspective, I have no problem with this, we're ~never going to switch away from RUSTC_LOG. It sounds like from the tracing side this is not ideal but still a reasonable trade-off.
This is a 'nice to have' IMO: It would of course be great to say 'enable these logs by adding |
This implements the warning in `tracing-subscriber` only, as mentioned in tokio-rs#975 (comment). It warns whenever directives are parsed, including programmatically and through environment variables. It does not include the suggested new API which returns the filters that wouldn't be parsed. - List filters that would be ignored - Mention 'static max level' - Describe how to enable the logging Example output: ``` $ RUST_LOG=off,debug,silenced[x]=trace cargo run -q warning: some trace filter directives would enable traces that are disabled statically | `debug` would enable the DEBUG level for all targets | `silenced[x]=trace` would enable the TRACE level for the `silenced` target | the static max level is info note: to enable DEBUG logging, remove the `max_level_info` feature ``` Fixes: tokio-rs#975
This implements the warning in `tracing-subscriber` only, as mentioned in tokio-rs#975 (comment). It warns whenever directives are parsed, including programmatically and through environment variables. It does not include the suggested new API which returns the filters that wouldn't be parsed. - List filters that would be ignored - Mention 'static max level' - Describe how to enable the logging Example output: ``` $ RUST_LOG=off,debug,silenced[x]=trace cargo run -q warning: some trace filter directives would enable traces that are disabled statically | `debug` would enable the DEBUG level for all targets | `silenced[x]=trace` would enable the TRACE level for the `silenced` target | the static max level is info note: to enable DEBUG logging, remove the `max_level_info` feature ``` Fixes: tokio-rs#975
This implements the warning in `tracing-subscriber` only, as mentioned in tokio-rs#975 (comment). It warns whenever directives are parsed, including programmatically and through environment variables. It does not include the suggested new API which returns the filters that wouldn't be parsed. - List filters that would be ignored - Mention 'static max level' - Describe how to enable the logging Example output: ``` $ RUST_LOG=off,debug,silenced[x]=trace cargo run -q warning: some trace filter directives would enable traces that are disabled statically | `debug` would enable the DEBUG level for all targets | `silenced[x]=trace` would enable the TRACE level for the `silenced` target | the static max level is info note: to enable DEBUG logging, remove the `max_level_info` feature ``` Fixes: tokio-rs#975
This implements the warning in `tracing-subscriber` only, as mentioned in tokio-rs#975 (comment). It warns whenever directives are parsed, including programmatically and through environment variables. It does not include the suggested new API which returns the filters that wouldn't be parsed. - List filters that would be ignored - Mention 'static max level' - Describe how to enable the logging Example output: ``` $ RUST_LOG=off,debug,silenced[x]=trace cargo run -q warning: some trace filter directives would enable traces that are disabled statically | `debug` would enable the DEBUG level for all targets | `silenced[x]=trace` would enable the TRACE level for the `silenced` target | the static max level is info note: to enable DEBUG logging, remove the `max_level_info` feature ``` Fixes: tokio-rs#975
This implements the warning in `tracing-subscriber` only, as mentioned in tokio-rs#975 (comment). It warns whenever directives are parsed, including programmatically and through environment variables. It does not include the suggested new API which returns the filters that wouldn't be parsed. - List filters that would be ignored - Mention 'static max level' - Describe how to enable the logging Example output: ``` $ RUST_LOG=off,debug,silenced[x]=trace cargo run -q warning: some trace filter directives would enable traces that are disabled statically | `debug` would enable the DEBUG level for all targets | `silenced[x]=trace` would enable the TRACE level for the `silenced` target | the static max level is info note: to enable DEBUG logging, remove the `max_level_info` feature ``` Fixes: tokio-rs#975
## Motivation Fixes #975. ## Solution This implements the warning in `tracing-subscriber` only, as mentioned in #975 (comment). It warns whenever directives are parsed, including programmatically and through environment variables. It does not include the suggested new API which returns the filters that wouldn't be parsed. - List filters that would be ignored - Mention 'static max level' - Describe how to enable the logging Example output: ``` $ RUST_LOG=off,debug,silenced[x]=trace cargo run -q warning: some trace filter directives would enable traces that are disabled statically | `debug` would enable the DEBUG level for all targets | `silenced[x]=trace` would enable the TRACE level for the `silenced` target = note: the static max level is info = note: to enable DEBUG logging, remove the `max_level_info` feature ``` ![image](https://user-images.githubusercontent.com/23638587/95243324-77dc6a00-07de-11eb-8ed3-6ee2109940d4.png)
…io-rs#990) ## Motivation Fixes tokio-rs#975. ## Solution This implements the warning in `tracing-subscriber` only, as mentioned in tokio-rs#975 (comment). It warns whenever directives are parsed, including programmatically and through environment variables. It does not include the suggested new API which returns the filters that wouldn't be parsed. - List filters that would be ignored - Mention 'static max level' - Describe how to enable the logging Example output: ``` $ RUST_LOG=off,debug,silenced[x]=trace cargo run -q warning: some trace filter directives would enable traces that are disabled statically | `debug` would enable the DEBUG level for all targets | `silenced[x]=trace` would enable the TRACE level for the `silenced` target = note: the static max level is info = note: to enable DEBUG logging, remove the `max_level_info` feature ``` ![image](https://user-images.githubusercontent.com/23638587/95243324-77dc6a00-07de-11eb-8ed3-6ee2109940d4.png)
## Motivation Fixes #975. ## Solution This implements the warning in `tracing-subscriber` only, as mentioned in #975 (comment). It warns whenever directives are parsed, including programmatically and through environment variables. It does not include the suggested new API which returns the filters that wouldn't be parsed. - List filters that would be ignored - Mention 'static max level' - Describe how to enable the logging Example output: ``` $ RUST_LOG=off,debug,silenced[x]=trace cargo run -q warning: some trace filter directives would enable traces that are disabled statically | `debug` would enable the DEBUG level for all targets | `silenced[x]=trace` would enable the TRACE level for the `silenced` target = note: the static max level is info = note: to enable DEBUG logging, remove the `max_level_info` feature ``` ![image](https://user-images.githubusercontent.com/23638587/95243324-77dc6a00-07de-11eb-8ed3-6ee2109940d4.png)
This didn't get implemented as part of #990, but especially as rustc keeps adding more and more complicated tracing configuration (e.g. rust-lang/rust#81932, which compiles two different versions of tracing), I think it would be helpful to mention |
Feature Request
I tried to write the title using the
tracing
terminology, but I might have gotten it wrong. Here is a concrete use case:Motivation
In
rustc
, we disabletrace
anddebug
logging by default for performance reasons, using themax_level_info
feature. This is very confusing to new contributors: they adddebug!("x")
to the code and runRUSTC_LOG=debug rustc
, but no debug information appears.It would be great to show a warning when using
RUSTC_LOG=debug
but logs at thedebug
level are disabled; I'm imagining something like this:Ideally this would happen whenever debug logging would normally be enabled, e.g. for
RUSTC_LOG=rustc_resolve
(which shows debug logging only for that module). However for a first pass I'd be ok with hard-coding this for=debug
.Alternatives
See also rust-lang/rust#76608.
The text was updated successfully, but these errors were encountered: