Skip to content

Commit

Permalink
Merge pull request #2738 from reubenmiller/log-disable-ansi-colours
Browse files Browse the repository at this point in the history
feat(logs): only enable ansi colors in logs when stderr is a terminal
  • Loading branch information
reubenmiller authored Feb 26, 2024
2 parents 76bb05f + 2d0383a commit bbdd177
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/common/tedge_config/src/system_services/log_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use camino::Utf8Path;

use crate::system_services::SystemConfig;
use crate::system_services::SystemServiceError;
use std::io::IsTerminal;
use std::str::FromStr;

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

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

0 comments on commit bbdd177

Please sign in to comment.