Skip to content

Commit

Permalink
Don't register a tracing dispatcher if no tracing env var was set.
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Jul 31, 2020
1 parent 358e21e commit 401033c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/librustc_driver/lib.rs
Expand Up @@ -1233,6 +1233,12 @@ pub fn init_rustc_env_logger() {
/// log 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(_) => {}
}
let builder = tracing_subscriber::FmtSubscriber::builder();

let builder = builder.with_env_filter(tracing_subscriber::EnvFilter::from_env(env));
Expand Down

0 comments on commit 401033c

Please sign in to comment.