use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LoggingConfig {
#[serde(default = "default_log_level")]
pub level: String,
#[serde(default = "default_true")]
pub structured: bool,
#[serde(default = "default_log_format")]
pub format: String,
#[serde(default = "default_log_targets")]
pub targets: Vec<String>,
#[serde(default)]
pub file: Option<LoggingFileConfig>,
}
fn default_true() -> bool { true }
fn default_log_level() -> String { "info".to_string() }
fn default_log_format() -> String { "json".to_string() }
fn default_log_targets() -> Vec<String> { vec!["console".to_string()] }
impl Default for LoggingConfig {
fn default() -> Self {
Self {
level: default_log_level(),
structured: true,
format: default_log_format(),
targets: default_log_targets(),
file: None,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LoggingFileConfig {
pub path: String,
#[serde(default)]
pub max_size: Option<String>,
#[serde(default)]
pub max_files: Option<u32>,
#[serde(default)]
pub compress: Option<bool>,
}