macro_rules! log {
($($input:tt)+) => { ... };
}
Expand description
Logs a message at the specified level.
This macro will generically log with the specified Level
and format!
based argument list.
§Named optional parameters
Named optional parameters are parameters for logging macros to configure this log record.
Each parameter is optional and no order is required. It can appear at the beginning or end of a log macro argument list, but cannot appear among the formatting arguments.
Name | Type / Basic Syntax | Description |
---|---|---|
logger | Arc<Logger> or Logger | If specified, the given logger will be used instead of the global default logger. |
kv | { key = value } | Key-value pairs for structured logs. See documentation of module kv for more. |
§Examples
use spdlog::{log, Level};
let data = (42, "Forty-two");
// Using the global default logger
log!(Level::Info, "received data: {}, {}", data.0, data.1);
// Or using the specified logger, and structured logging
log!(logger: app_events, Level::Info, "received data", kv: { data:? });