aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/rust-analyzer/src/bin/main.rs9
-rw-r--r--docs/dev/README.md3
2 files changed, 10 insertions, 2 deletions
diff --git a/crates/rust-analyzer/src/bin/main.rs b/crates/rust-analyzer/src/bin/main.rs
index afc96505f..97246cae6 100644
--- a/crates/rust-analyzer/src/bin/main.rs
+++ b/crates/rust-analyzer/src/bin/main.rs
@@ -60,7 +60,14 @@ fn try_main() -> Result<()> {
60 } 60 }
61 } 61 }
62 62
63 setup_logging(flags.log_file.as_deref(), flags.no_log_buffering)?; 63 let mut log_file = flags.log_file.as_deref();
64
65 let env_log_file = env::var("RA_LOG_FILE").ok();
66 if let Some(env_log_file) = env_log_file.as_deref() {
67 log_file = Some(Path::new(env_log_file));
68 }
69
70 setup_logging(log_file, flags.no_log_buffering)?;
64 let verbosity = flags.verbosity(); 71 let verbosity = flags.verbosity();
65 72
66 match flags.subcommand { 73 match flags.subcommand {
diff --git a/docs/dev/README.md b/docs/dev/README.md
index e81f1e74c..a394b8501 100644
--- a/docs/dev/README.md
+++ b/docs/dev/README.md
@@ -131,7 +131,8 @@ Logging is done by both rust-analyzer and VS Code, so it might be tricky to figu
131 131
132Inside rust-analyzer, we use the standard `log` crate for logging, and `env_logger` for logging frontend. 132Inside rust-analyzer, we use the standard `log` crate for logging, and `env_logger` for logging frontend.
133By default, log goes to stderr, but the stderr itself is processed by VS Code. 133By default, log goes to stderr, but the stderr itself is processed by VS Code.
134`--log-file <PATH>` CLI argument allows logging to file. 134`--log-file <PATH>` CLI argument allows logging to file.
135Setting the `RA_LOG_FILE=<PATH>` environment variable will also log to file, it will also override `--log-file`.
135 136
136To see stderr in the running VS Code instance, go to the "Output" tab of the panel and select `rust-analyzer`. 137To see stderr in the running VS Code instance, go to the "Output" tab of the panel and select `rust-analyzer`.
137This shows `eprintln!` as well. 138This shows `eprintln!` as well.