diff --git a/src/filter/min_level.rs b/src/filter/level.rs similarity index 77% rename from src/filter/min_level.rs rename to src/filter/level.rs index 8a8fe19..dd4b04d 100644 --- a/src/filter/min_level.rs +++ b/src/filter/level.rs @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use log::LevelFilter; use log::Metadata; use crate::filter::Filter; @@ -28,13 +27,13 @@ use crate::filter::FilterResult; /// - `Debug` /// - `Trace` /// -/// If MaxLevel is set to `Info`, it will allow `Error`, `Warn`, and `Info` logs. +/// If LevelFilter is set to `Info`, it will allow `Error`, `Warn`, and `Info` logs. /// -/// If MaxLevel is set to `Off`, it will reject all logs. +/// If LevelFilter is set to `Off`, it will reject all logs. #[derive(Debug, Clone)] -pub struct MaxLevel(pub LevelFilter); +pub struct LevelFilter(pub log::LevelFilter); -impl MaxLevel { +impl LevelFilter { pub(crate) fn filter(&self, metadata: &Metadata) -> FilterResult { let level = metadata.level(); if level <= self.0 { @@ -44,14 +43,15 @@ impl MaxLevel { } } } -impl From for Filter { - fn from(filter: MaxLevel) -> Self { - Filter::MaxLevel(filter) - } -} impl From for Filter { fn from(filter: LevelFilter) -> Self { - Filter::MaxLevel(MaxLevel(filter)) + Filter::Level(filter) + } +} + +impl From for Filter { + fn from(filter: log::LevelFilter) -> Self { + Filter::Level(LevelFilter(filter)) } } diff --git a/src/filter/mod.rs b/src/filter/mod.rs index ff1870c..3617713 100644 --- a/src/filter/mod.rs +++ b/src/filter/mod.rs @@ -13,10 +13,10 @@ // limitations under the License. pub use self::custom::CustomFilter; -pub use self::min_level::MaxLevel; +pub use self::level::LevelFilter; mod custom; -mod min_level; +mod level; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum FilterResult { @@ -30,14 +30,14 @@ pub enum FilterResult { #[derive(Debug)] pub enum Filter { - MaxLevel(MaxLevel), + Level(LevelFilter), Custom(CustomFilter), } impl Filter { pub(crate) fn filter(&self, metadata: &log::Metadata) -> FilterResult { match self { - Filter::MaxLevel(filter) => filter.filter(metadata), + Filter::Level(filter) => filter.filter(metadata), Filter::Custom(filter) => filter.filter(metadata), } }