1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
#[macro_export] macro_rules! LOG { (target: $target:expr, $level:expr, $($arg:tt)+) => ({ let level = $level; if level <= unsafe { $crate::MAX_LEVEL } { let metadata = $crate::Metadata::new(level, $target.to_owned()); let record = $crate::Record::new( metadata, format!($($arg)+), Some(module_path!().to_string()), Some(file!().to_string()), Some(line!()) ); $crate::LOG.push(record); } }); ($level:expr, $($arg:tt)+) => (LOG!(target: module_path!().to_string(), $level, $($arg)+)) } #[macro_export] macro_rules! ERROR { (target: $target:expr, $($arg:tt)*) => ( LOG!(target: $target, $crate::Level::Error, $($arg)+); ); ($($arg:tt)*) => ( LOG!($crate::Level::Error, $($arg)+); ) } #[macro_export] macro_rules! WARN { (target: $target:expr, $($arg:tt)*) => ( LOG!(target: $target, $crate::Level::Warn, $($arg)+); ); ($($arg:tt)*) => ( LOG!($crate::Level::Warn, $($arg)+); ) } #[macro_export] macro_rules! INFO { (target: $target:expr, $($arg:tt)*) => ( LOG!(target: $target, $crate::Level::Info, $($arg)+); ); ($($arg:tt)*) => ( LOG!($crate::Level::Info, $($arg)+); ) } #[macro_export] macro_rules! DEBUG { (target: $target:expr, $($arg:tt)*) => ( LOG!(target: $target, $crate::Level::Debug, $($arg)+); ); ($($arg:tt)*) => ( LOG!($crate::Level::Debug, $($arg)+); ) } #[macro_export] macro_rules! TRACE { (target: $target:expr, $($arg:tt)*) => ( LOG!(target: $target, $crate::Level::Trace, $($arg)+); ); ($($arg:tt)*) => ( LOG!($crate::Level::Trace, $($arg)+); ) }