context-logger 0.1.4

A lightweight, ergonomic library for adding structured context to your logs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::common::{RecordExt, check_logger_once};

pub mod common;

#[test]
fn test_smoke() {
    check_logger_once(|entry| {
        let val = entry.get_record("answer").unwrap();
        assert_eq!(val, 42);
        Ok(())
    });

    let _guard = context_logger::LogContext::new()
        .record("answer", 42)
        .enter();
    log::info!("Smoke on the water, fire in the sky");
}