log::macros::log_enabled![src]
macro_rules! log_enabled( ($lvl:expr) => ({ let lvl = $lvl; (lvl != ::log::DEBUG || cfg!(not(ndebug))) && lvl <= ::log::log_level() && ::log::mod_enabled(lvl, module_path!()) }) )
A macro to test whether a log level is enabled for the current module.
Example
#![feature(phase)] #[phase(plugin, link)] extern crate log; fn main() { struct Point { x: int, y: int } fn some_expensive_computation() -> Point { Point { x: 1, y: 2 } } if log_enabled!(log::DEBUG) { let x = some_expensive_computation(); debug!("x.x = {}, x.y = {}", x.x, x.y); } }#![feature(phase)] #[phase(plugin, link)] extern crate log; if log_enabled!(log::DEBUG) { let x = some_expensive_computation(); debug!("x.x = {}, x.y = {}", x.x, x.y); }