diff --git a/bin/bgp/src/logging.rs b/bin/bgp/src/logging.rs index 1af1279..8b0092c 100644 --- a/bin/bgp/src/logging.rs +++ b/bin/bgp/src/logging.rs @@ -1,5 +1,7 @@ //! What the daemon logs, and how much. +use std::io::IsTerminal; + use clap::Args; use tracing::Level; use tracing_subscriber::EnvFilter; @@ -23,7 +25,12 @@ impl LoggingArgs { let filter = EnvFilter::builder() .from_env_lossy() .add_directive(format!("{OURS}={}", self.level).parse()?); - tracing_subscriber::fmt().with_env_filter(filter).init(); + // Colours for a person at a terminal; plain text for the journal + // or a file, where escape codes are noise. + tracing_subscriber::fmt() + .with_env_filter(filter) + .with_ansi(std::io::stdout().is_terminal()) + .init(); Ok(()) } }