about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2020-07-28 15:49:04 +0200
committerOliver Scherer <github35764891676564198441@oli-obk.de>2020-07-31 22:42:16 +0200
commit401033c68486bc7672cc87e0f4c5b4862e96c778 (patch)
tree3e78f866db4605aa7b6dfb0d6ffc353a5ef9d2c8
parent358e21ee781cbcee19ff96b3824b583611e860a5 (diff)
downloadrust-401033c68486bc7672cc87e0f4c5b4862e96c778.tar.gz
rust-401033c68486bc7672cc87e0f4c5b4862e96c778.zip
Don't register a tracing dispatcher if no tracing env var was set.
-rw-r--r--src/librustc_driver/lib.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs
index 177fb2c2ec6..7af640c109e 100644
--- a/src/librustc_driver/lib.rs
+++ b/src/librustc_driver/lib.rs
@@ -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));