exception matching

This commit is contained in:
Robin Appelman 2024-07-22 22:56:40 +02:00
commit 4bf687461f
7 changed files with 185 additions and 23 deletions

View file

@ -1,6 +1,8 @@
use serde::Deserialize;
use std::fmt::{Display, Formatter};
#[derive(Debug, Default, PartialEq, Clone, Copy)]
#[derive(Debug, Default, PartialEq, Clone, Copy, Deserialize)]
#[serde(from = "i64")]
pub enum LogLevel {
Debug,
Info,
@ -28,6 +30,12 @@ impl From<i64> for LogLevel {
}
}
impl LogLevel {
pub fn matches(&self, matcher_level: LogLevel) -> bool {
matcher_level == *self || matcher_level == LogLevel::Exception || *self == LogLevel::Unknown
}
}
#[derive(Debug, PartialEq, Clone)]
pub struct LoggingStatement {
pub level: LogLevel,