Skip to content

Commit 67d6be2

Browse files
committed
feat(log): make console_logger() accept RUSTUP_TERM_COLOR and NO_COLOR
1 parent 509714d commit 67d6be2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/cli/log.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@ fn console_logger<S>(process: Process) -> impl Layer<S>
6464
where
6565
S: Subscriber + for<'span> LookupSpan<'span>,
6666
{
67-
let has_ansi = process.stderr().is_a_tty();
67+
let has_ansi = match process.var("RUSTUP_TERM_COLOR") {
68+
Ok(s) if s.eq_ignore_ascii_case("always") => true,
69+
Ok(s) if s.eq_ignore_ascii_case("never") => false,
70+
// `RUSTUP_TERM_COLOR` is prioritized over `NO_COLOR`.
71+
_ if process.var("NO_COLOR").is_ok() => false,
72+
_ => process.stderr().is_a_tty(),
73+
};
6874
let maybe_rust_log_directives = process.var("RUST_LOG");
6975
let logger = tracing_subscriber::fmt::layer()
7076
.with_writer(move || process.stderr())

0 commit comments

Comments
 (0)