log::log_enabled!
+
+ [−]
+
+ [src]
++macro_rules! log_enabled { + (target: $target:expr, $lvl:expr) => ({ + let lvl = $lvl; + !cfg!(log_level = "off") && + (lvl <= $crate::LogLevel::Error || !cfg!(log_level = "error")) && + (lvl <= $crate::LogLevel::Warn || !cfg!(log_level = "warn")) && + (lvl <= $crate::LogLevel::Debug || !cfg!(log_level = "debug")) && + (lvl <= $crate::LogLevel::Info || !cfg!(log_level = "info")) && + lvl <= $crate::max_log_level() && + $crate::__enabled(lvl, $target) + }); + ($lvl:expr) => (log_enabled!(target: module_path!(), $lvl)) +} ++
Determines if a message logged at the specified level in that module will +be logged.
+ +This can be used to avoid expensive computation of log message arguments if +the message would be ignored anyway.
+ +Examples
+use log::LogLevel::Debug; + +if log_enabled!(Debug) { + debug!("expensive debug data: {}", expensive_call()); +} ++