#[macro_export]
macro_rules! log {
($lvl:expr, $($arg:tt)+) => ({
static LOC: $crate::LogLocation = $crate::LogLocation {
line: line!(),
file: file!(),
module_path: module_path!(),
};
let lvl = $lvl;
if !cfg!(log_level = "off") &&
(lvl <= $crate::LogLevel::Error || !cfg!(log_level = "error")) &&
(lvl <= $crate::LogLevel::Warn || !cfg!(log_level = "warn")) &&
(lvl <= $crate::LogLevel::Debug || !cfg!(log_level = "debug")) &&
(lvl <= $crate::LogLevel::Info || !cfg!(log_level = "info")) &&
lvl <= $crate::max_log_level() {
$crate::log(lvl, &LOC, format_args!($($arg)+))
}
})
}
#[macro_export]
macro_rules! error {
($($arg:tt)*) => (
log!($crate::LogLevel::Error, $($arg)*);
)
}
#[macro_export]
macro_rules! warn {
($($arg:tt)*) => (
log!($crate::LogLevel::Warn, $($arg)*);
)
}
#[macro_export]
macro_rules! info {
($($arg:tt)*) => (
log!($crate::LogLevel::Info, $($arg)*);
)
}
#[macro_export]
macro_rules! debug {
($($arg:tt)*) => (
log!($crate::LogLevel::Debug, $($arg)*);
)
}
#[macro_export]
macro_rules! trace {
($($arg:tt)*) => (
log!($crate::LogLevel::Trace, $($arg)*);
)
}
#[macro_export]
macro_rules! log_enabled {
($lvl:expr) => ({
let lvl = $lvl;
!cfg!(log_level = "off") &&
(lvl <= $crate::LogLevel::Error || !cfg!(log_level = "error")) &&
(lvl <= $crate::LogLevel::Warn || !cfg!(log_level = "warn")) &&
(lvl <= $crate::LogLevel::Debug || !cfg!(log_level = "debug")) &&
(lvl <= $crate::LogLevel::Info || !cfg!(log_level = "info")) &&
lvl <= $crate::max_log_level() &&
$crate::enabled(lvl, module_path!())
})
}