macro_rules! log {
($log_level:expr, $($format_string:literal)PW_FMT_CONCAT+ $(, $args:expr)* $(,)?) => { ... };
($log_level:expr, $format_string:literal $(, $args:expr)* $(,)?) => { ... };
}Expand description
Emit a log message using core::fmt format string semantics.
log takes 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::{log, LogLevel};
log!(LogLevel::Info, "Log fact: A {} log has a Janka hardness of {} lbf.",
"Spruce Pine" as &str, 700 as i32);Multiple string literals can be concatenated using the PW_FMT_CONCAT operator.
This is particularly useful when writing wrapper macros that need to prepend a prefix to a format string.
use pw_log::{log, LogLevel};
macro_rules! my_info_log {
($format_string:literal $(, $args:expr)* $(,)?) => {
log!(LogLevel::Info, "[MyModule] " PW_FMT_CONCAT $format_string $(, $args)*)
};
}
my_info_log!("The answer is {}.", 42 as i32);