Skip to content

Commit

Permalink
use env variable to control thread ids in rustc_log
Browse files Browse the repository at this point in the history
  • Loading branch information
SparrowLii committed Oct 10, 2023
1 parent 1516ca1 commit 2dcc828
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions compiler/rustc_log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,21 @@ 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)
.with_ansi(color_logs)
.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")) {
Expand Down

0 comments on commit 2dcc828

Please sign in to comment.