Description
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 disable trace
and debug
logging by default for performance reasons, using the max_level_info
feature. This is very confusing to new contributors: they add debug!("x")
to the code and run RUSTC_LOG=debug rustc
, but no debug information appears.
It would be great to show a warning when using RUSTC_LOG=debug
but logs at the debug
level are disabled; I'm imagining something like this:
$ RUSTC_LOG=debug rustc
warning: debug logging has been disabled
note: to show debug logging, do not enable the `max_level_info` feature
# info-level logging follows
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
- Don't print any warning; require the downstream crate to parse the RUSTC_LOG variable themselves. This is the current situation; it avoids cluttering logs if the user already knows a level has been disabled at the cost of being confusing if they don't.
- Print a warning, but in a different format than the one I mentioned here.
- Only print the warning when the downstream crate opts-in.
See also rust-lang/rust#76608.