Macro log::log [] [src]

macro_rules! log {
    ($lvl:expr, $($arg:tt)+) => { ... };
}
🔬 This is a nightly-only experimental API. (rustc_private)

use the crates.io log library instead

The standard logging macro

This macro will generically log over a provided level (of type u32) with a format!-based argument list. See documentation in std::fmt for details on how to use the syntax.

Examples

#[macro_use] extern crate log;

fn main() {
    log!(log::WARN, "this is a warning {}", "message");
    log!(log::DEBUG, "this is a debug message");
    log!(6, "this is a custom logging level: {level}", level=6);
}Run

Assumes the binary is main:

$ RUST_LOG=warn ./main
WARN:main: this is a warning message
$ RUST_LOG=debug ./main
DEBUG:main: this is a debug message
WARN:main: this is a warning message
$ RUST_LOG=6 ./main
DEBUG:main: this is a debug message
WARN:main: this is a warning message
6:main: this is a custom logging level: 6