Skip to main content

r_log

Macro r_log 

Source
macro_rules! r_log {
    ($level:expr, $($arg:tt)*) => { ... };
}
Expand description

Dispatches a formatted log message to the global logger.

This macro is the primary interface for logging throughout the application. It behaves exactly like standard Rust formatting macros (e.g., println! or format!), allowing you to easily interpolate variables into your log messages. Messages sent via r_log! are always processed and distributed to all registered sinks (like terminal and files), regardless of whether the application is compiled in debug or release mode.

§Arguments

  • $level - The severity of the log, provided as a LogLevel variant (e.g., LogLevel::Info, LogLevel::Warning).
  • $arg - A format string and an arbitrary number of formatting arguments, following standard std::fmt syntax.

§Examples

// Basic usage with a simple string
r_log!(LogLevel::Info, "System initialized successfully");

// Formatting with variables
let port = 8080;
r_log!(LogLevel::SuccessEvent, "Server listening on port {}", port);

// Logging complex errors
r_log!(LogLevel::Error, "Failed to load configuration file at {}: {}", path, err);