diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-10-10 14:07:47 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-10 14:07:47 +0200 |
| commit | 0bc5696dd96708e0cc0447779d7cbdd46cadc2a7 (patch) | |
| tree | 3e8e50ef0163bd43550b44ac4e51a0a51a1d9f69 | |
| parent | 5c37696f6026f91a869d51ab555cb0efae488972 (diff) | |
| parent | 2dcc828863ed8515df3a0efac507535581d162de (diff) | |
| download | rust-0bc5696dd96708e0cc0447779d7cbdd46cadc2a7.tar.gz rust-0bc5696dd96708e0cc0447779d7cbdd46cadc2a7.zip | |
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.
| -rw-r--r-- | compiler/rustc_log/src/lib.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/compiler/rustc_log/src/lib.rs b/compiler/rustc_log/src/lib.rs index 3e43bcb3b8f..0c9ec556549 100644 --- a/compiler/rustc_log/src/lib.rs +++ b/compiler/rustc_log/src/lib.rs @@ -74,6 +74,11 @@ pub fn init_env_logger(env: &str) -> Result<(), Error> { Some(v) => &v != "0", }; + let verbose_thread_ids = match env::var_os(String::from(env) + "_THREAD_IDS") { + None => false, + Some(v) => &v == "1", + }; + let layer = tracing_tree::HierarchicalLayer::default() .with_writer(io::stderr) .with_indent_lines(true) @@ -81,9 +86,9 @@ pub fn init_env_logger(env: &str) -> Result<(), Error> { .with_targets(true) .with_verbose_exit(verbose_entry_exit) .with_verbose_entry(verbose_entry_exit) - .with_indent_amount(2); - #[cfg(all(parallel_compiler, debug_assertions))] - let layer = layer.with_thread_ids(true).with_thread_names(true); + .with_indent_amount(2) + .with_thread_ids(verbose_thread_ids) + .with_thread_names(verbose_thread_ids); let subscriber = tracing_subscriber::Registry::default().with(filter).with(layer); match env::var(format!("{env}_BACKTRACE")) { |
