json/json.rs
1//! JSON output at DEBUG level with source file locations enabled.
2//!
3//! Run with: `cargo run --example json`
4
5use tiny_tracing::{Level, LogFormat, Logger, info, warn};
6
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8 Logger::new()
9 .with_level(Level::DEBUG)
10 .with_format(LogFormat::Json)
11 .with_file(true)
12 .init()?;
13
14 info!(user_id = 42, action = "login", "structured event");
15 warn!("something worth a second look");
16 Ok(())
17}