Make the log macro's definition more consise

This commit is contained in:
Michael Mikovsky
2026-02-20 14:34:32 -07:00
parent 219c7254fb
commit 6c6625e9ad
6 changed files with 44 additions and 80 deletions
+31 -2
View File
@@ -1,9 +1,9 @@
// Choose if the macros are enabled based on the feature setting
#[cfg(feature = "log")]
pub mod macros;
mod log_enabled;
#[cfg(not(feature = "log"))]
pub mod macros_disabled;
mod log_disabled;
mod pretty_logger;
@@ -81,3 +81,32 @@ pub type SetupLogger = extern "C" fn(logger: &'static dyn Logger);
pub extern "C" fn setup_logger(logger: &'static dyn Logger) {
set_logger(logger);
}
// Macro Definitions
#[macro_export]
macro_rules! debug {
($($arg:tt)*) => {
$crate::log!($crate::logger::LogLevel::Debug, $($arg)*)
};
}
#[macro_export]
macro_rules! info {
($($arg:tt)*) => {
$crate::log!($crate::logger::LogLevel::Info, $($arg)*)
};
}
#[macro_export]
macro_rules! warn {
($($arg:tt)*) => {
$crate::log!($crate::logger::LogLevel::Warn, $($arg)*)
};
}
#[macro_export]
macro_rules! error {
($($arg:tt)*) => {
$crate::log!($crate::logger::LogLevel::Error, $($arg)*)
};
}