Macro log_macro::log

source ·
macro_rules! log {
    ( $val:expr $(,)? ) => { ... };
    ( $($val:expr),+ $(,)? ) => { ... };
}
Expand description

Macro to print variable(s) with values nicely (stripped from release builds)

print string only:

log!("hello"); // -> hello

print variable + its value:

let animals = vec!["cat", "dog"];
log!(animals); // -> animals: ["cat", "dog"]

print multiple variables (each variable printed on new line):

let animals = vec!["cat", "dog"];
let fish = vec!["salmon", "tuna"];
log!(animals, fish); -> animals: ["cat", "dog"]

credit for improvements goes to Icarium-Lifestealer: https://www.reddit.com/r/rust/comments/15wd5u6/comment/jx0pl1o/