X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Futil%2Flogger.rs;h=e727723c16dedbc6bb4713b4bd137238884ce0b5;hb=50e16c9573ef5af43abf4837e6199c6526429d42;hp=bccc8cd21cfabd6df2f230ddd00db1ce2d39e0f1;hpb=0029f04fce6beba29e60b2c227d51bcf1ba15545;p=rust-lightning diff --git a/src/util/logger.rs b/src/util/logger.rs index bccc8cd2..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,9 +121,11 @@ 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, Record}; + use util::logger::{Logger, Level}; use util::test_utils::TestLogger; use std::sync::{Arc};