use serde::{Deserialize, Serialize};
use tracing::level_filters::LevelFilter;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Config {
pub log_dir: String,
pub trace_frames: bool,
pub level: String,
pub format: String,
pub include_location: bool,
pub thread_ids: bool,
pub thread_names: bool,
}
impl Default for Config {
fn default() -> Self {
Self {
log_dir: "logs".to_string(),
trace_frames: false,
level: "info".to_string(),
format: "pretty".to_string(),
include_location: false,
thread_ids: false,
thread_names: false,
}
}
}
impl Config {
pub fn get_level_filter(&self) -> LevelFilter {
match self.level.to_lowercase().as_str() {
"error" => LevelFilter::ERROR,
"warn" => LevelFilter::WARN,
"info" => LevelFilter::INFO,
"debug" => LevelFilter::DEBUG,
"trace" => LevelFilter::TRACE,
_ => LevelFilter::INFO, }
}
}