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

Always register a tracing subscriber, even if no env var is set #89623

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions compiler/rustc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1253,12 +1253,6 @@ pub fn init_rustc_env_logger() {
/// tracing crate version. In contrast to `init_rustc_env_logger` it allows you to choose an env var
/// other than `RUSTC_LOG`.
pub fn init_env_logger(env: &str) {
// Don't register a dispatcher if there's no filter to print anything
match std::env::var(env) {
Err(_) => return,
Ok(s) if s.is_empty() => return,
Ok(_) => {}
}
Comment on lines -1256 to -1261
Copy link
Contributor

Choose a reason for hiding this comment

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

if we wanted to have a way to completely disable logging, we could consider special-casing RUSTC_LOG=off, instead of "no value", but, since the perf run indicates that the performance difference between "no subscriber" and "levels disabled" is negligable, it's probably not worth messing with...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it may be more noticeable if debug assertions are turned on, but I have to test that locally. Since I often run with RUSTC_LOG and without, and don't notice something, it can't be too bad though.

let color_logs = match std::env::var(String::from(env) + "_COLOR") {
Ok(value) => match value.as_ref() {
"always" => true,
Expand Down