]> git.lizzy.rs Git - rust.git/commitdiff
output to log file if RA_LOG_FILE is defined in environment
authorrezural <rezural@protonmail.com>
Sun, 20 Jun 2021 23:33:57 +0000 (09:33 +1000)
committerrezural <rezural@protonmail.com>
Sun, 20 Jun 2021 23:33:57 +0000 (09:33 +1000)
crates/rust-analyzer/src/bin/main.rs

index afc96505fa3a2ef4f0acef3a159ef75bc235b2a0..97246cae6f00aff5e190c6c0fb35577c9283f2e5 100644 (file)
@@ -60,7 +60,14 @@ fn try_main() -> Result<()> {
         }
     }
 
-    setup_logging(flags.log_file.as_deref(), flags.no_log_buffering)?;
+    let mut log_file = flags.log_file.as_deref();
+
+    let env_log_file = env::var("RA_LOG_FILE").ok();
+    if let Some(env_log_file) = env_log_file.as_deref() {
+        log_file = Some(Path::new(env_log_file));
+    }
+
+    setup_logging(log_file, flags.no_log_buffering)?;
     let verbosity = flags.verbosity();
 
     match flags.subcommand {