Skip to main content Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. Rust
  4. pw_kernel
  5. log_if
  6. logf_if

logf_if

Macro logf_if 

Source
macro_rules! logf_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 printf format string semantics if condition is true.

logf_if takes an expr condition, a LogLevel, a printf 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::logf_if;

const LOG_FACTS: bool = true;
logf_if!(LOG_FACTS, LogLevel::Info, "Log fact: A %s log has a Janka hardness of %d lbf.",
    "Spruce Pine", 700);