Skip to content

Commit 0bc5696

Browse files
authored
Rollup merge of #116586 - SparrowLii:parallel_log, r=oli-obk
use env variable to control thread ids in rustc_log Currently, when parallel rustc is enabled, even if the number of threads is 1, the thread ID will be included before all the logs. E.g. `WARN rustc_mir_build::thir::pattern::const_to_pat ...` => `2:rustcWARN rustc_mir_build::thir::pattern::const_to_pat ...` This makes the logs confusing and results in inconsistent UI test results for serial and parallel rustc. Therefore I think we should let users decide whether thread id information is needed through explicit control.
2 parents 5c37696 + 2dcc828 commit 0bc5696

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

compiler/rustc_log/src/lib.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,21 @@ pub fn init_env_logger(env: &str) -> Result<(), Error> {
7474
Some(v) => &v != "0",
7575
};
7676

77+
let verbose_thread_ids = match env::var_os(String::from(env) + "_THREAD_IDS") {
78+
None => false,
79+
Some(v) => &v == "1",
80+
};
81+
7782
let layer = tracing_tree::HierarchicalLayer::default()
7883
.with_writer(io::stderr)
7984
.with_indent_lines(true)
8085
.with_ansi(color_logs)
8186
.with_targets(true)
8287
.with_verbose_exit(verbose_entry_exit)
8388
.with_verbose_entry(verbose_entry_exit)
84-
.with_indent_amount(2);
85-
#[cfg(all(parallel_compiler, debug_assertions))]
86-
let layer = layer.with_thread_ids(true).with_thread_names(true);
89+
.with_indent_amount(2)
90+
.with_thread_ids(verbose_thread_ids)
91+
.with_thread_names(verbose_thread_ids);
8792

8893
let subscriber = tracing_subscriber::Registry::default().with(filter).with(layer);
8994
match env::var(format!("{env}_BACKTRACE")) {

0 commit comments

Comments
 (0)