Skip to content

Commit 72075f6

Browse files
committed
feat: add support for NO_COLOR standard for log lines
Signed-off-by: James Rhodes <[email protected]>
1 parent c3f3cc3 commit 72075f6

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/common/tedge_config/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ tracing = { workspace = true }
3939
tracing-subscriber = { workspace = true }
4040
url = { workspace = true }
4141
which = { workspace = true }
42+
yansi = { workspace = true }
4243

4344
[dev-dependencies]
4445
assert_matches = { workspace = true }

crates/common/tedge_config/src/system_toml/log_level.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ macro_rules! subscriber_builder {
1212
() => {
1313
tracing_subscriber::fmt()
1414
.with_writer(std::io::stderr)
15-
.with_ansi(std::io::stderr().is_terminal())
15+
.with_ansi(std::io::stderr().is_terminal() && yansi::Condition::no_color())
1616
.with_timer(tracing_subscriber::fmt::time::UtcTime::rfc_3339())
1717
};
1818
}
@@ -75,7 +75,7 @@ fn logger(
7575
) -> Result<Arc<dyn tracing::Subscriber + Send + Sync>, SystemTomlError> {
7676
let subscriber = tracing_subscriber::fmt()
7777
.with_writer(std::io::stderr)
78-
.with_ansi(std::io::stderr().is_terminal())
78+
.with_ansi(std::io::stderr().is_terminal() && yansi::Condition::no_color())
7979
.with_timer(tracing_subscriber::fmt::time::UtcTime::rfc_3339());
8080
let log_level = flags
8181
.log_level
@@ -124,7 +124,7 @@ pub fn get_log_level(
124124
pub fn set_log_level(log_level: tracing::Level) {
125125
let subscriber = tracing_subscriber::fmt()
126126
.with_writer(std::io::stderr)
127-
.with_ansi(std::io::stderr().is_terminal())
127+
.with_ansi(std::io::stderr().is_terminal() && yansi::Condition::no_color())
128128
.with_timer(tracing_subscriber::fmt::time::UtcTime::rfc_3339());
129129

130130
if std::env::var("RUST_LOG").is_ok() {

0 commit comments

Comments
 (0)