diff options
Diffstat (limited to 'src/filters/mod.rs')
-rw-r--r-- | src/filters/mod.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/filters/mod.rs b/src/filters/mod.rs index 62dc04b..525ff27 100644 --- a/src/filters/mod.rs +++ b/src/filters/mod.rs @@ -1,5 +1,5 @@ #![allow(clippy::new_ret_no_self)] -use std::ops; +use std::{ops, fmt}; use num_derive::FromPrimitive; use num_traits::FromPrimitive as _; @@ -59,7 +59,7 @@ impl From<bool> for Inclusion { /// The main filter trait. /// /// Filters are usually handled as a `Box<dyn Filter>`. -pub trait Filter<Early, Late>: Send + Sync { +pub trait Filter<Early, Late>: Send + Sync + fmt::Debug { /// Determine early (before processing all events) whether the log stands a chance to be /// included. /// @@ -118,6 +118,12 @@ impl<E: 'static, L: 'static> ops::BitAnd<Box<dyn Filter<E, L>>> for Box<dyn Filt } } +impl<E, L> fmt::Debug for AndFilter<E, L> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "({:?}) and ({:?})", self.0, self.1) + } +} + struct OrFilter<E, L>(Box<dyn Filter<E, L>>, Box<dyn Filter<E, L>>); impl<E, L> Filter<E, L> for OrFilter<E, L> { @@ -144,6 +150,12 @@ impl<E: 'static, L: 'static> ops::BitOr<Box<dyn Filter<E, L>>> for Box<dyn Filte } } +impl<E, L> fmt::Debug for OrFilter<E, L> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "({:?}) or ({:?})", self.0, self.1) + } +} + struct NotFilter<E, L>(Box<dyn Filter<E, L>>); impl<E, L> Filter<E, L> for NotFilter<E, L> { @@ -164,6 +176,12 @@ impl<E: 'static, L: 'static> ops::Not for Box<dyn Filter<E, L>> { } } +impl<E, L> fmt::Debug for NotFilter<E, L> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "not ({:?})", self.0) + } +} + #[cfg(test)] mod tests { use super::*; |