Merge pull request #91 from ariard/logging_interface
[rust-lightning] / src / util / macro_logger.rs
1 use util::logger::Record;
2
3 macro_rules! log_internal {
4         ($self: ident, $lvl:expr, $($arg:tt)+) => (
5                 &$self.logger.log(&Record::new($lvl, format_args!($($arg)+), module_path!(), file!(), line!()));
6         );
7 }
8
9 macro_rules! log_error {
10         ($self: ident, $($arg:tt)*) => (
11                 #[cfg(not(any(feature = "max_level_off")))]
12                 log_internal!($self, $crate::util::logger::Level::Error, $($arg)*);
13         )
14 }
15
16 macro_rules! log_warn {
17         ($self: ident, $($arg:tt)*) => (
18                 #[cfg(not(any(feature = "max_level_off", feature = "max_level_error")))]
19                 log_internal!($self, $crate::util::logger::Level::Warn, $($arg)*);
20         )
21 }
22
23 macro_rules! log_info {
24         ($self: ident, $($arg:tt)*) => (
25                 #[cfg(not(any(feature = "max_level_off", feature = "max_level_error", feature = "max_level_warn")))]
26                 log_internal!($self, $crate::util::logger::Level::Info, $($arg)*);
27         )
28 }
29
30 macro_rules! log_debug {
31         ($self: ident, $($arg:tt)*) => (
32                 #[cfg(not(any(feature = "max_level_off", feature = "max_level_error", feature = "max_level_warn", feature = "max_level_info")))]
33                 log_internal!($self, $crate::util::logger::Level::Debug, $($arg)*);
34         )
35 }
36
37 macro_rules! log_trace {
38         ($self: ident, $($arg:tt)*) => (
39                 #[cfg(not(any(feature = "max_level_off", feature = "max_level_error", feature = "max_level_warn", feature = "max_level_info", feature = "max_level_debug")))]
40                 log_internal!($self, $crate::util::logger::Level::Trace, $($arg)*);
41         )
42 }