tracing — logs structurés
Intermédiairecargo add tracing tracing-subscriber
use tracing::{info, instrument, warn};
#[instrument] // crée automatiquement un span avec les arguments
async fn traiter(id: u32) {
info!(id, "traitement démarré");
warn!("ressource lente");
}
fn main() {
tracing_subscriber::fmt::init(); // niveau via RUST_LOG=info
}