log::debug! [-] [+] [src]

macro_rules! debug {
    ($($arg:tt)*) => (if cfg!(debug_assertions) { log!(::log::DEBUG, $($arg)*) })
}

A convenience macro for logging at the debug log level. This macro can also be omitted at compile time by passing --cfg ndebug to the compiler. If this option is not passed, then debug statements will be compiled.

Examples

#[macro_use] extern crate log; fn main() { debug!("x = {x}, y = {y}", x=10, y=20); }
#[macro_use] extern crate log;

fn main() {
    debug!("x = {x}, y = {y}", x=10, y=20);
}

Assumes the binary is main:

$ RUST_LOG=debug ./main
DEBUG:main: x = 10, y = 20