Skip to content

Commit 3f375ff

Browse files
committed
document logging envvars in devguide
1 parent 70fe53f commit 3f375ff

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

‎compiler/rustc_log/src/lib.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ pub struct LoggerConfig {
6666

6767
impl LoggerConfig {
6868
pub fn from_env(env: &str) -> Self {
69+
// NOTE: documented in the dev guide. If you change this, also update it!
6970
LoggerConfig {
7071
filter: env::var(env),
7172
color_logs: env::var(format!("{env}_COLOR")),

‎src/doc/rustc-dev-guide/src/tracing.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@ To see the logs, you need to set the `RUSTC_LOG` environment variable to your lo
1212
The full syntax of the log filters can be found in the [rustdoc
1313
of `tracing-subscriber`](https://docs.rs/tracing-subscriber/0.2.24/tracing_subscriber/filter/struct.EnvFilter.html#directives).
1414

15+
## Environment variables
16+
17+
This is an overview of the environment variables rustc accepts to customize
18+
its tracing output. The definition of these can mostly be found in `compiler/rustc_log/src/lib.rs`.
19+
20+
| Name | Usage |
21+
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
22+
| `RUSTC_LOG` | Tracing filters (see the rest of this page) |
23+
| `RUSTC_LOG_COLOR` | `always`, `never` or `auto`. |
24+
| `RUSTC_LOG_ENTRY_EXIT` | if set and not '0', log span entry/exit. |
25+
| `RUSTC_LOG_THREAD_IDS` | if set and equal to '1', also log thread ids. |
26+
| `RUSTC_LOG_BACKTRACE` | Capture and print a backtrace if a trace is emitted with a target that matches the provided string value. |
27+
| `RUSTC_LOG_LINES` | If `1`, indents log lines based on depth. |
28+
| `RUSTC_LOG_FORMAT_JSON` | If `1`, outputs logs as JSON. The exact parameters can be found in `rustc_log/src/lib.rs` but the format is *UNSTABLE*. |
29+
| `RUSTC_LOG_OUTPUT_TARGET` | If provided, logs go to the provided file name instead of stderr. |
30+
31+
32+
33+
1534
## Function level filters
1635

1736
Lots of functions in rustc are annotated with

0 commit comments

Comments
 (0)