X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Futil%2Fmacro_logger.rs;fp=src%2Futil%2Fmacro_logger.rs;h=607f8fe4e581bdeb8ef7c0cdf26a8fb139045c20;hb=0029f04fce6beba29e60b2c227d51bcf1ba15545;hp=0000000000000000000000000000000000000000;hpb=587f2b39fc30400ecadcb4145eeac4c896d5f51c;p=rust-lightning diff --git a/src/util/macro_logger.rs b/src/util/macro_logger.rs new file mode 100644 index 00000000..607f8fe4 --- /dev/null +++ b/src/util/macro_logger.rs @@ -0,0 +1,42 @@ +use util::logger::Record; + +macro_rules! log_internal { + ($self: ident, $lvl:expr, $($arg:tt)+) => ( + &$self.logger.log(&Record::new($lvl, format_args!($($arg)+), module_path!(), file!(), line!())); + ); +} + +macro_rules! log_error { + ($self: ident, $($arg:tt)*) => ( + #[cfg(not(any(feature = "max_level_off")))] + log_internal!($self, $crate::util::logger::Level::Error, $($arg)*); + ) +} + +macro_rules! log_warn { + ($self: ident, $($arg:tt)*) => ( + #[cfg(not(any(feature = "max_level_off", feature = "max_level_error")))] + log_internal!($self, $crate::util::logger::Level::Warn, $($arg)*); + ) +} + +macro_rules! log_info { + ($self: ident, $($arg:tt)*) => ( + #[cfg(not(any(feature = "max_level_off", feature = "max_level_error", feature = "max_level_warn")))] + log_internal!($self, $crate::util::logger::Level::Info, $($arg)*); + ) +} + +macro_rules! log_debug { + ($self: ident, $($arg:tt)*) => ( + #[cfg(not(any(feature = "max_level_off", feature = "max_level_error", feature = "max_level_warn", feature = "max_level_info")))] + log_internal!($self, $crate::util::logger::Level::Debug, $($arg)*); + ) +} + +macro_rules! log_trace { + ($self: ident, $($arg:tt)*) => ( + #[cfg(not(any(feature = "max_level_off", feature = "max_level_error", feature = "max_level_warn", feature = "max_level_info", feature = "max_level_debug")))] + log_internal!($self, $crate::util::logger::Level::Trace, $($arg)*); + ) +}