use loggix::{with_fields, Logger};
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let logger = Logger::new().build();
logger
.with_fields(Default::default())
.info("Starting application...")?;
with_fields!(
"request_id" => "abc-123",
"method" => "GET",
"path" => "/api/v1/users"
)
.debug("Processing API request")?;
with_fields!(
"user" => "john_doe",
"role" => "admin",
"session" => "5f2c"
)
.info("User authenticated")?;
with_fields!(
"latency_ms" => 1500,
"threshold_ms" => 1000,
"endpoint" => "/api/search"
)
.warn("High latency detected")?;
with_fields!(
"operation" => "db_query",
"table" => "users",
"error_code" => "ERR_TIMEOUT"
)
.error("Database operation failed")?;
Ok(())
}