Move log level to config file

This commit is contained in:
Andras Schmelczer 2025-12-07 15:06:08 +00:00
parent 8439bd8b92
commit 78a706ab8d
9 changed files with 47 additions and 26 deletions

View file

@ -0,0 +1,27 @@
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub enum LogLevel {
Error,
Warn,
Info,
Debug,
Trace,
}
impl LogLevel {
pub fn as_tracing_level(self) -> tracing::Level {
match self {
Self::Error => tracing::Level::ERROR,
Self::Warn => tracing::Level::WARN,
Self::Info => tracing::Level::INFO,
Self::Debug => tracing::Level::DEBUG,
Self::Trace => tracing::Level::TRACE,
}
}
pub fn is_debug_or_trace(self) -> bool {
matches!(self, Self::Debug | Self::Trace)
}
}