Macro log

Source
macro_rules! log {
    (target: $target:expr, kvs: $kvs:expr, $lvl:expr, $($arg:tt)+) => { ... };
    (target: $target:expr, $lvl:expr, $($arg:tt)+) => { ... };
    (kvs: $kvs:expr, $lvl:expr, $($arg:tt)+) => { ... };
    ($lvl:expr, $($arg:tt)+) => { ... };
}
Expand description

The standard logging macro.

ยงExamples

use udp_logger_rs::info;

// The standard logging we know and love
info!("hello");
info!("hello",);
info!("hello {}", "cats");
info!("hello {}", "cats",);
info!(target: "MyApp", "hello");
info!(target: "MyApp", "hello",);
info!(target: "MyApp", "hello {}", "cats");
info!(target: "MyApp", "hello {}", "cats",);

// The kv logging we hope to love
let ctx: Vec<(String, String)> = vec![
   ("cat_1".into(), "chashu".into()),
   ("cat_2".into(), "nori".into()),
];

// default target
info!(kvs: &ctx, "hello");
info!(kvs: &ctx, "hello",);
info!(kvs: &ctx, "hello {}", "cats");
info!(kvs: &ctx, "hello {}", "cats",);

// with target provided
info!(target: "MyApp", kvs: &ctx, "hello");
info!(target: "MyApp", kvs: &ctx, "hello",);
info!(target: "MyApp", kvs: &ctx, "hello {}", "cats");
info!(target: "MyApp", kvs: &ctx, "hello {}", "cats",);