mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-09 06:47:59 -06:00
Make the log macro's definition more consise
This commit is contained in:
+31
-2
@@ -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)*)
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user