mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-08 22:38:01 -06:00
Make the log macro's definition more consise
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
// Macros that are used that just drop the inside variables
|
||||
#[macro_export]
|
||||
macro_rules! log {
|
||||
($level:expr, $fmt:tt) => {{}};
|
||||
($level:expr, $fmt:tt, $($arg:expr),*) => {{}};
|
||||
}
|
||||
@@ -33,31 +33,3 @@ macro_rules! log {
|
||||
);
|
||||
}};
|
||||
}
|
||||
|
||||
#[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)*)
|
||||
};
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
// Macros that are used that just drop the inside variables
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! debug {
|
||||
($fmt:tt) => {{
|
||||
let _ = $fmt;
|
||||
}};
|
||||
($fmt:tt, $($arg:expr),*) => {{
|
||||
let _ = $fmt;
|
||||
$(let _ = $arg;)*
|
||||
}};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! info {
|
||||
($fmt:tt) => {{
|
||||
let _ = $fmt;
|
||||
}};
|
||||
($fmt:tt, $($arg:expr),*) => {{
|
||||
let _ = $fmt;
|
||||
$(let _ = $arg;)*
|
||||
}};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! warn {
|
||||
($fmt:tt) => {{
|
||||
let _ = $fmt;
|
||||
}};
|
||||
($fmt:tt, $($arg:expr),*) => {{
|
||||
let _ = $fmt;
|
||||
$(let _ = $arg;)*
|
||||
}};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! error {
|
||||
($fmt:tt) => {{
|
||||
let _ = $fmt;
|
||||
}};
|
||||
($fmt:tt, $($arg:expr),*) => {{
|
||||
let _ = $fmt;
|
||||
$(let _ = $arg;)*
|
||||
}};
|
||||
}
|
||||
+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