diff --git a/src/main.rs b/src/main.rs index 0254c67..98ea6cb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -75,5 +75,14 @@ async fn main() -> Result<()> { fn init_tracing(verbose: bool) { let default = if verbose { "pixelpass=trace,iroh=info" } else { "pixelpass=info,iroh=warn" }; let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new(default)); - tracing_subscriber::fmt().with_env_filter(filter).with_target(false).init(); + // Tracing MUST write to stderr. `tracing_subscriber::fmt()` defaults its + // writer to stdout, but with `--output json` stdout carries the JSON event + // stream the `--gui` front-end parses (see `common::output`) — logging there + // interleaves log lines into that stream (corrupting events and starving the + // GUI's stderr-tail diagnostics). Pin it to stderr to honor that contract. + tracing_subscriber::fmt() + .with_writer(std::io::stderr) + .with_env_filter(filter) + .with_target(false) + .init(); }