Move log level to config file
This commit is contained in:
parent
8439bd8b92
commit
78a706ab8d
9 changed files with 47 additions and 26 deletions
27
sync-server/src/utils/log_level.rs
Normal file
27
sync-server/src/utils/log_level.rs
Normal 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)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue