Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::net::SocketAddr;
use std::sync::Arc;

use tokio::task::JoinHandle;
use tracing::info;

use crate::bootstrap::logging;
use crate::cache::image::manager::ImageCacheService;
Expand Down Expand Up @@ -42,6 +43,8 @@ pub async fn run(configuration: Configuration, api_version: &Version) -> Running

logging::setup(&log_level);

log_configuration(&configuration).await;

let configuration = Arc::new(configuration);

// Get configuration settings needed to build the app dependencies and
Expand Down Expand Up @@ -190,3 +193,10 @@ pub async fn run(configuration: Configuration, api_version: &Version) -> Running
tracker_data_importer_handle: tracker_statistics_importer_handle,
}
}

/// It logs the final configuration removing secrets.
async fn log_configuration(configuration: &Configuration) {
let mut setting = configuration.get_all().await.clone();
setting.remove_secrets();
info!("Configuration:\n{}", setting.to_json());
}
2 changes: 1 addition & 1 deletion src/bootstrap/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn tracing_stdout_init(filter: LevelFilter, style: &TraceStyle) {
TraceStyle::Json => builder.json().init(),
};

info!("logging initialized.");
info!("Logging initialized");
}

#[derive(Debug)]
Expand Down
6 changes: 3 additions & 3 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,17 @@ impl Info {
let env_var_config_toml_path = ENV_VAR_CONFIG_TOML_PATH.to_string();

let config_toml = if let Ok(config_toml) = env::var(env_var_config_toml) {
println!("Loading configuration from environment variable {config_toml} ...");
println!("Loading extra configuration from environment variable {config_toml} ...");
Some(config_toml)
} else {
None
};

let config_toml_path = if let Ok(config_toml_path) = env::var(env_var_config_toml_path) {
println!("Loading configuration from file: `{config_toml_path}` ...");
println!("Loading extra configuration from file: `{config_toml_path}` ...");
config_toml_path
} else {
println!("Loading configuration from default configuration file: `{default_config_toml_path}` ...");
println!("Loading extra configuration from default configuration file: `{default_config_toml_path}` ...");
default_config_toml_path
};

Expand Down
20 changes: 20 additions & 0 deletions src/config/v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,26 @@ impl Settings {
"***".clone_into(&mut self.mail.smtp.credentials.password);
self.auth.secret_key = SecretKey::new("***");
}

/// Encodes the configuration to TOML.
///
/// # Panics
///
/// Will panic if it can't be converted to TOML.
#[must_use]
pub fn to_toml(&self) -> String {
toml::to_string(self).expect("Could not encode TOML value")
}

/// Encodes the configuration to JSON.
///
/// # Panics
///
/// Will panic if it can't be converted to JSON.
#[must_use]
pub fn to_json(&self) -> String {
serde_json::to_string_pretty(self).expect("Could not encode JSON value")
}
}

impl Validator for Settings {
Expand Down
2 changes: 1 addition & 1 deletion src/console/commands/seeder/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ use tracing::level_filters::LevelFilter;
pub fn setup(level: LevelFilter) {
tracing_subscriber::fmt().with_max_level(level).init();

debug!("logging initialized.");
debug!("Logging initialized");
}