Move log level to config file
This commit is contained in:
parent
8439bd8b92
commit
78a706ab8d
9 changed files with 47 additions and 26 deletions
|
|
@ -3,7 +3,10 @@ use std::time::Duration;
|
|||
use log::debug;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::consts::{DEFAULT_LOG_DIRECTORY, DEFAULT_LOG_ROTATION_INTERVAL};
|
||||
use crate::{
|
||||
consts::{DEFAULT_LOG_DIRECTORY, DEFAULT_LOG_LEVEL, DEFAULT_LOG_ROTATION_INTERVAL},
|
||||
utils::log_level::LogLevel,
|
||||
};
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||
pub struct LoggingConfig {
|
||||
|
|
@ -12,6 +15,9 @@ pub struct LoggingConfig {
|
|||
|
||||
#[serde(default = "default_log_rotation", with = "humantime_serde")]
|
||||
pub log_rotation: Duration,
|
||||
|
||||
#[serde(default = "default_log_level")]
|
||||
pub log_level: LogLevel,
|
||||
}
|
||||
|
||||
impl Default for LoggingConfig {
|
||||
|
|
@ -19,6 +25,7 @@ impl Default for LoggingConfig {
|
|||
Self {
|
||||
log_directory: default_log_directory(),
|
||||
log_rotation: default_log_rotation(),
|
||||
log_level: default_log_level(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -32,3 +39,8 @@ fn default_log_rotation() -> Duration {
|
|||
debug!("Using default log rotation: {DEFAULT_LOG_ROTATION_INTERVAL:?}");
|
||||
DEFAULT_LOG_ROTATION_INTERVAL
|
||||
}
|
||||
|
||||
fn default_log_level() -> LogLevel {
|
||||
debug!("Using default log level: Info");
|
||||
DEFAULT_LOG_LEVEL
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue