|
|
|
@ -70,6 +70,7 @@ pub fn sclog(level: Level, file: &str, line: u32, function: &str,
|
|
|
|
|
/// Return the function name, but for now just return <rust> as Rust
|
|
|
|
|
/// has no macro to return the function name, but may in the future,
|
|
|
|
|
/// see: https://github.com/rust-lang/rfcs/pull/1719
|
|
|
|
|
#[macro_export(local_inner_macros)]
|
|
|
|
|
macro_rules!function {
|
|
|
|
|
() => {{ "<rust>" }}
|
|
|
|
|
}
|
|
|
|
@ -78,8 +79,8 @@ macro_rules!function {
|
|
|
|
|
macro_rules!do_log {
|
|
|
|
|
($level:expr, $file:expr, $line:expr, $function:expr, $code:expr,
|
|
|
|
|
$($arg:tt)*) => {
|
|
|
|
|
if get_log_level() >= $level as i32 {
|
|
|
|
|
sclog($level, $file, $line, $function, $code,
|
|
|
|
|
if $crate::log::get_log_level() >= $level as i32 {
|
|
|
|
|
$crate::log::sclog($level, $file, $line, $function, $code,
|
|
|
|
|
&(format!($($arg)*)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -88,35 +89,35 @@ macro_rules!do_log {
|
|
|
|
|
#[macro_export]
|
|
|
|
|
macro_rules!SCLogNotice {
|
|
|
|
|
($($arg:tt)*) => {
|
|
|
|
|
do_log!(Level::Notice, file!(), line!(), function!(), 0, $($arg)*);
|
|
|
|
|
$crate::do_log!($crate::log::Level::Notice, file!(), line!(), $crate::function!(), 0, $($arg)*);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
|
macro_rules!SCLogInfo {
|
|
|
|
|
($($arg:tt)*) => {
|
|
|
|
|
do_log!(Level::Info, file!(), line!(), function!(), 0, $($arg)*);
|
|
|
|
|
$crate::do_log!($crate::log::Level::Info, file!(), line!(), $crate::function!(), 0, $($arg)*);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
|
macro_rules!SCLogPerf {
|
|
|
|
|
($($arg:tt)*) => {
|
|
|
|
|
do_log!(Level::Perf, file!(), line!(), function!(), 0, $($arg)*);
|
|
|
|
|
$crate::do_log!($crate::log::Level::Perf, file!(), line!(), $crate::function!(), 0, $($arg)*);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
|
macro_rules!SCLogConfig {
|
|
|
|
|
($($arg:tt)*) => {
|
|
|
|
|
do_log!(Level::Config, file!(), line!(), function!(), 0, $($arg)*);
|
|
|
|
|
$crate::do_log!($crate::log::Level::Config, file!(), line!(), $crate::function!(), 0, $($arg)*);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
|
macro_rules!SCLogError {
|
|
|
|
|
($($arg:tt)*) => {
|
|
|
|
|
do_log!(Level::Error, file!(), line!(), function!(), 0, $($arg)*);
|
|
|
|
|
$crate::do_log!($crate::log::Level::Error, file!(), line!(), $crate::function!(), 0, $($arg)*);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -125,7 +126,7 @@ macro_rules!SCLogError {
|
|
|
|
|
#[macro_export]
|
|
|
|
|
macro_rules!SCLogDebug {
|
|
|
|
|
($($arg:tt)*) => {
|
|
|
|
|
do_log!(Level::Debug, file!(), line!(), function!(), 0, $($arg)*);
|
|
|
|
|
do_log!($crate::log::Level::Debug, file!(), line!(), $crate::function!(), 0, $($arg)*);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -134,7 +135,7 @@ macro_rules!SCLogDebug {
|
|
|
|
|
#[cfg(not(feature = "debug"))]
|
|
|
|
|
#[macro_export]
|
|
|
|
|
macro_rules!SCLogDebug {
|
|
|
|
|
($last:expr) => { let _ = &$last; let _ = Level::Debug; };
|
|
|
|
|
($last:expr) => { let _ = &$last; let _ = $crate::log::Level::Debug; };
|
|
|
|
|
($one:expr, $($arg:tt)*) => { let _ = &$one; SCLogDebug!($($arg)*); };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|