macro_rules! log_if {
($condition:expr, $log_level:expr, $format_string:literal $(,)?) => { ... };
($condition:expr, $log_level:expr, $format_string:literal, $($args:expr),* $(,)?) => { ... };
}Expand description
Emit a log message using core::fmt format string semantics if condition is true.
log_if takes an expr condition, a LogLevel, a core::fmt style format string,
and necessary arguments to that string and emits a log message to the logging backend.
use pw_log::LogLevel;
use log_if::log_if;
const LOG_FACTS: bool = true;
log_if!(LOG_FACTS, LogLevel::Info, "Log fact: A {} log has a Janka hardness of {} lbf.",
"Spruce Pine" as &str, 700 as i32);