stderr/stderr.rs
1//! Logging to stderr so stdout stays free for program output.
2//!
3//! Run with: `cargo run --example stderr`
4//! Try: `cargo run --example stderr 2>/dev/null` (only the data is printed)
5
6use tiny_tracing::{Logger, Output, info};
7
8fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let _guard = Logger::new().with_output(Output::Stderr).init()?;
10
11 info!("this log line goes to stderr");
12 println!("this is program output, on stdout");
13
14 Ok(())
15}