Skip to content

Commit 2d0383a

Browse files
committed
feat(logs): only enable ansi colors in logs when stderr is a terminal
Signed-off-by: Reuben Miller <reuben.d.miller@gmail.com>
1 parent 76bb05f commit 2d0383a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

crates/common/tedge_config/src/system_services/log_config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use camino::Utf8Path;
22

33
use crate::system_services::SystemConfig;
44
use crate::system_services::SystemServiceError;
5+
use std::io::IsTerminal;
56
use std::str::FromStr;
67

78
pub fn get_log_level(
@@ -27,6 +28,7 @@ pub fn get_log_level(
2728
pub fn set_log_level(log_level: tracing::Level) {
2829
let subscriber = tracing_subscriber::fmt()
2930
.with_writer(std::io::stderr)
31+
.with_ansi(std::io::stderr().is_terminal())
3032
.with_timer(tracing_subscriber::fmt::time::UtcTime::rfc_3339());
3133

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

0 commit comments

Comments
 (0)