use std::path::{Path, PathBuf}; use crate::LogLevel; #[derive(Debug, Clone, PartialEq, Eq)] pub struct LoggerConfig { pub(crate) log_level: LogLevel, pub(crate) log_to_file: bool, pub(crate) log_file_path: PathBuf, pub(crate) log_to_stdout: bool, pub(crate) stdout_color: bool, pub(crate) stdout_include_time: bool, pub(crate) file_include_time: bool, } impl LoggerConfig { pub fn level(mut self, level: LogLevel) -> Self { self.log_level = level; self } pub fn log_to_file(mut self, f: bool) -> Self { self.log_to_file = f; self } pub fn colored_stdout(mut self, c: bool) -> Self { self.stdout_color = c; self } pub fn log_to_stdout(mut self, s: bool) -> Self { self.log_to_stdout = s; self } pub fn log_path>(mut self, p: P) -> Self { self.log_file_path = p.as_ref().to_path_buf(); self } pub fn stdout_include_time(mut self, i: bool) -> Self { self.stdout_include_time = i; self } pub fn file_include_time(mut self, i: bool) -> Self { self.file_include_time = i; self } } impl Default for LoggerConfig { fn default() -> Self { Self { log_level: LogLevel::Debug, log_to_file: true, log_file_path: "app.log".into(), log_to_stdout: true, stdout_color: true, stdout_include_time: false, file_include_time: false, } } }