Skip to content

Commit 94c82de

Browse files
Rollup merge of #152897 - jdonszelmann:logging, r=jieyouxu
Add optional json logging I became slightly frustrated with rust's logging output, and wanted to experiment a little with slightly postprocessing it with custom scripts. I think this is a pretty uninteresting change otherwise, shouldn't affect anyone else nor bother anyone. It's small enough that we can remove it again, nor is any of this stable or expected to be. r? @jieyouxu
2 parents 6cfb6d7 + 5f502f0 commit 94c82de

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

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)