X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Futil%2Flogger.rs;h=e727723c16dedbc6bb4713b4bd137238884ce0b5;hb=50e16c9573ef5af43abf4837e6199c6526429d42;hp=720bccf4140d8f7053c7e0e96b1015a2523716b2;hpb=7318a97b157cdf69b41dda1ea918fea142d26399;p=rust-lightning diff --git a/src/util/logger.rs b/src/util/logger.rs index 720bccf4..e727723c 100644 --- a/src/util/logger.rs +++ b/src/util/logger.rs @@ -7,17 +7,21 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -/// There is currently 2 ways to filter log messages. First one, by using compilation flag, e.g "max_level_off". -/// The second one, client-side by implementing check against Record Level field, e.g TestLogger in test_utils. -/// Each module may have its own Logger or share one. +//! Log traits live here, which are called throughout the library to provide useful information for +//! debugging purposes. +//! +//! There is currently 2 ways to filter log messages. First one, by using compilation features, e.g "max_level_off". +//! The second one, client-side by implementing check against Record Level field. +//! Each module may have its own Logger or share one. use std::cmp; use std::fmt; +use std::sync::Arc; static LOG_LEVEL_NAMES: [&'static str; 6] = ["OFF", "ERROR", "WARN", "INFO", "DEBUG", "TRACE"]; /// An enum representing the available verbosity levels of the logger. -#[derive(Copy, Clone, Eq, Debug, Hash)] +#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)] pub enum Level { ///Designates logger being silent Off, @@ -33,13 +37,6 @@ pub enum Level { Trace, } -impl PartialEq for Level { - #[inline] - fn eq(&self, other: &Level) -> bool { - *self as usize == *other as usize - } -} - impl PartialOrd for Level { #[inline] fn partial_cmp(&self, other: &Level) -> Option { @@ -124,6 +121,8 @@ pub trait Logger: Sync + Send { fn log(&self, record: &Record); } +pub(crate) struct LogHolder<'a> { pub(crate) logger: &'a Arc } + #[cfg(test)] mod tests { use util::logger::{Logger, Level};