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!(
"user" => "john_doe",
"role" => "admin"
)
.info("User logged in successfully")?;
with_fields!(
"component" => "auth",
"attempt" => 3,
"ip" => "192.168.1.100"
)
.warn("Multiple login attempts detected")?;
with_fields!(
"operation" => "database_query",
"table" => "users",
"duration_ms" => 1500
)
.error("Query timeout exceeded")?;
with_fields!(
"request_id" => "abc-123",
"path" => "/api/v1/users",
"method" => "POST",
"status" => 201
)
.debug("API request processed")?;
Ok(())
}