Skip to content

Commit

Permalink
don't use ANSI escape codes when running as background service
Browse files Browse the repository at this point in the history
  • Loading branch information
syphar committed Aug 12, 2024
1 parent e579f2d commit 8715875
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/bin/cratesfyi.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::env;
use std::fmt::Write;
use std::io::{self, IsTerminal};
use std::net::SocketAddr;
use std::path::PathBuf;
use std::str::FromStr;
Expand Down Expand Up @@ -33,8 +34,13 @@ fn main() {
// through rustwide.
rustwide::logging::init_with(LogTracer::new());

let is_interactive_terminal = {
let stdout = io::stdout();
stdout.is_terminal()
};

let tracing_registry = tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer())
.with(tracing_subscriber::fmt::layer().with_ansi(is_interactive_terminal))
.with(
EnvFilter::builder()
.with_default_directive(Directive::from_str("docs_rs=info").unwrap())
Expand Down

0 comments on commit 8715875

Please sign in to comment.