Rewrite Channel resend tracking to make it much more reliable
[rust-lightning] / src / util / logger.rs
index bccc8cd21cfabd6df2f230ddd00db1ce2d39e0f1..e727723c16dedbc6bb4713b4bd137238884ce0b5 100644 (file)
@@ -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<cmp::Ordering> {
@@ -124,9 +121,11 @@ pub trait Logger: Sync + Send {
        fn log(&self, record: &Record);
 }
 
+pub(crate) struct LogHolder<'a> { pub(crate) logger: &'a Arc<Logger> }
+
 #[cfg(test)]
 mod tests {
-       use util::logger::{Logger, Level, Record};
+       use util::logger::{Logger, Level};
        use util::test_utils::TestLogger;
        use std::sync::{Arc};