feat: set max loglevel in logger configuration

This commit is contained in:
Chance 2025-04-16 12:59:35 -04:00 committed by lily
parent 29522c14f9
commit dfb3b04c9d
Signed by: lily
GPG key ID: 601F3263FBCBC4B9
3 changed files with 32 additions and 9 deletions

View file

@ -4,18 +4,19 @@ use crate::LogLevel;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LoggerConfig {
pub(crate) log_level: LogLevel,
pub(crate) log_level: Option<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,
pub(crate) crate_max_level: Option<LogLevel>,
}
impl LoggerConfig {
pub fn level(mut self, level: LogLevel) -> Self {
self.log_level = level;
self.log_level = Some(level);
self
}
@ -53,7 +54,8 @@ impl LoggerConfig {
impl Default for LoggerConfig {
fn default() -> Self {
Self {
log_level: LogLevel::Debug,
log_level: None,
crate_max_level: None,
log_to_file: true,
log_file_path: "app.log".into(),
log_to_stdout: true,