use std::path::PathBuf;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LogFormat {
Json,
Human,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RotationStrategy {
Daily,
Size(usize),
}
#[derive(Debug, Clone)]
pub struct LogRotationConfig {
pub strategy: RotationStrategy,
pub max_files: usize,
}
#[derive(Debug, Clone)]
pub struct LogConfig {
pub level: tracing::Level,
pub console_output: bool,
pub console_format: LogFormat,
pub console_colors: bool,
pub console_show_target: bool,
pub console_show_file: bool,
pub console_show_line: bool,
pub file_output: bool,
pub log_file: Option<PathBuf>,
pub file_format: LogFormat,
pub rotation: LogRotationConfig,
}
impl Default for LogRotationConfig {
fn default() -> Self {
Self {
strategy: RotationStrategy::Daily,
max_files: 7,
}
}
}
impl Default for LogConfig {
fn default() -> Self {
Self {
level: tracing::Level::INFO,
console_output: true,
console_format: LogFormat::Human,
console_colors: true,
console_show_target: true,
console_show_file: true,
console_show_line: true,
file_output: false,
log_file: None,
file_format: LogFormat::Json,
rotation: LogRotationConfig::default(),
}
}
}