Skip to content

Commit

Permalink
feat!: [torrust#878] make log_level config value mandatory
Browse files Browse the repository at this point in the history
Althought, it has a default value `info` so you can omit it in the TOML
config file.
  • Loading branch information
josecelano authored and da2ce7 committed Jun 20, 2024
1 parent 73dec71 commit 37a09aa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
7 changes: 3 additions & 4 deletions packages/configuration/src/v1/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct Logging {
/// Logging level. Possible values are: `Off`, `Error`, `Warn`, `Info`,
/// `Debug` and `Trace`. Default is `Info`.
#[serde(default = "Logging::default_log_level")]
pub log_level: Option<LogLevel>,
pub log_level: LogLevel,
}

impl Default for Logging {
Expand All @@ -20,8 +20,7 @@ impl Default for Logging {
}

impl Logging {
#[allow(clippy::unnecessary_wraps)]
fn default_log_level() -> Option<LogLevel> {
Some(LogLevel::Info)
fn default_log_level() -> LogLevel {
LogLevel::Info
}
}
2 changes: 1 addition & 1 deletion packages/test-helpers/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn ephemeral() -> Configuration {

let mut config = Configuration::default();

config.logging.log_level = Some(LogLevel::Off); // Change to `debug` for tests debugging
config.logging.log_level = LogLevel::Off; // Change to `debug` for tests debugging

// Ephemeral socket address for API
let api_port = 0u16;
Expand Down
5 changes: 1 addition & 4 deletions src/bootstrap/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ fn map_to_tracing_level_filter(log_level: &LogLevel) -> LevelFilter {
pub fn config() -> (Configuration, LevelFilter) {
let config = initialize_configuration();

let level: LevelFilter = match &config.logging.log_level {
None => LevelFilter::INFO,
Some(level) => map_to_tracing_level_filter(level),
};
let level: LevelFilter = map_to_tracing_level_filter(&config.logging.log_level);

(config, level)
}
Expand Down

0 comments on commit 37a09aa

Please sign in to comment.