This commit is contained in:
Chris Beck
2025-12-05 19:42:30 -07:00
parent f899d391b9
commit 35b274bbd3
3 changed files with 6 additions and 10 deletions
+1 -1
View File
@@ -239,7 +239,7 @@ where
D: serde::Deserializer<'de>,
{
let opt: Option<String> = Option::deserialize(deserializer)?;
Ok(opt.and_then(|s| Level::from_str(&s)))
Ok(opt.and_then(|s| Level::parse(&s)))
}
/// Deserialize a timestamp from Unix epoch (int or string) or RFC3339 string
+3 -7
View File
@@ -123,10 +123,8 @@ impl LogHandler {
for (origin, buffer) in buffers.iter() {
// Apply filter if present
if let Some(f) = filter {
if !origin.matches_filter(f) {
continue;
}
if filter.is_some_and(|f| !origin.matches_filter(f)) {
continue;
}
use std::fmt::Write;
@@ -287,9 +285,7 @@ impl LogHandler {
}
// Check if message matches route's filter (if any)
let filter_matches = route.filter.as_ref().map_or(true, |f| f.matches(log_msg));
if !filter_matches {
if !route.filter.as_ref().is_none_or(|f| f.matches(log_msg)) {
continue;
}
+2 -2
View File
@@ -57,7 +57,7 @@ impl Level {
/// - info, information
/// - debug
/// - trace
pub fn from_str(s: &str) -> Option<Self> {
pub fn parse(s: &str) -> Option<Self> {
match s.to_ascii_uppercase().as_str() {
"EMERGENCY" | "EMERG" => Some(Self::EMERGENCY),
"ALERT" => Some(Self::ALERT),
@@ -79,7 +79,7 @@ impl<'de> Deserialize<'de> for Level {
D: de::Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
Level::from_str(&s).ok_or_else(|| {
Level::parse(&s).ok_or_else(|| {
de::Error::custom(format!(
"unknown log level '{}', expected one of: emergency, alert, critical, error, warning, notice, info, debug, trace",
s