mirror of
https://codeberg.org/icewind/logsmash.git
synced 2026-06-03 10:04:12 +02:00
group matches by loglevel for faster matching
This commit is contained in:
parent
ece904f791
commit
7af8f0d63d
3 changed files with 74 additions and 28 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use serde::Deserialize;
|
||||
use std::fmt::{Display, Formatter};
|
||||
|
||||
#[derive(Debug, Default, PartialEq, Clone, Copy, Deserialize, Hash)]
|
||||
#[derive(Debug, Default, PartialEq, Clone, Copy, Deserialize, Hash, PartialOrd, Ord, Eq)]
|
||||
#[serde(from = "i64")]
|
||||
pub enum LogLevel {
|
||||
Debug = 0,
|
||||
|
|
@ -26,6 +26,18 @@ impl From<i64> for LogLevel {
|
|||
}
|
||||
|
||||
impl LogLevel {
|
||||
pub fn iter() -> impl Iterator<Item = LogLevel> {
|
||||
[
|
||||
LogLevel::Debug,
|
||||
LogLevel::Info,
|
||||
LogLevel::Warn,
|
||||
LogLevel::Error,
|
||||
LogLevel::Exception,
|
||||
LogLevel::Unknown,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
|
||||
pub fn matches(&self, matcher_level: LogLevel) -> bool {
|
||||
matcher_level == *self || matcher_level == LogLevel::Exception || *self == LogLevel::Unknown
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue