File tree Expand file tree Collapse file tree 3 files changed +32
-3
lines changed
Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ use std::net::SocketAddr;
22use std:: sync:: Arc ;
33
44use tokio:: task:: JoinHandle ;
5+ use tracing:: info;
56
67use crate :: bootstrap:: logging;
78use crate :: cache:: image:: manager:: ImageCacheService ;
@@ -42,6 +43,8 @@ pub async fn run(configuration: Configuration, api_version: &Version) -> Running
4243
4344 logging:: setup ( & log_level) ;
4445
46+ log_configuration ( & configuration) . await ;
47+
4548 let configuration = Arc :: new ( configuration) ;
4649
4750 // Get configuration settings needed to build the app dependencies and
@@ -190,3 +193,9 @@ pub async fn run(configuration: Configuration, api_version: &Version) -> Running
190193 tracker_data_importer_handle : tracker_statistics_importer_handle,
191194 }
192195}
196+
197+ async fn log_configuration ( configuration : & Configuration ) {
198+ let mut setting = configuration. get_all ( ) . await . clone ( ) ;
199+ setting. remove_secrets ( ) ;
200+ info ! ( "Configuration:\n {}" , setting. to_json( ) ) ;
201+ }
Original file line number Diff line number Diff line change @@ -141,17 +141,17 @@ impl Info {
141141 let env_var_config_toml_path = ENV_VAR_CONFIG_TOML_PATH . to_string ( ) ;
142142
143143 let config_toml = if let Ok ( config_toml) = env:: var ( env_var_config_toml) {
144- println ! ( "Loading configuration from environment variable {config_toml} ..." ) ;
144+ println ! ( "Loading extra configuration from environment variable {config_toml} ..." ) ;
145145 Some ( config_toml)
146146 } else {
147147 None
148148 } ;
149149
150150 let config_toml_path = if let Ok ( config_toml_path) = env:: var ( env_var_config_toml_path) {
151- println ! ( "Loading configuration from file: `{config_toml_path}` ..." ) ;
151+ println ! ( "Loading extra configuration from file: `{config_toml_path}` ..." ) ;
152152 config_toml_path
153153 } else {
154- println ! ( "Loading configuration from default configuration file: `{default_config_toml_path}` ..." ) ;
154+ println ! ( "Loading extra configuration from default configuration file: `{default_config_toml_path}` ..." ) ;
155155 default_config_toml_path
156156 } ;
157157
Original file line number Diff line number Diff line change @@ -81,6 +81,26 @@ impl Settings {
8181 "***" . clone_into ( & mut self . mail . smtp . credentials . password ) ;
8282 self . auth . secret_key = SecretKey :: new ( "***" ) ;
8383 }
84+
85+ /// Encodes the configuration to TOML.
86+ ///
87+ /// # Panics
88+ ///
89+ /// Will panic if it can't be converted to TOML.
90+ #[ must_use]
91+ pub fn to_toml ( & self ) -> String {
92+ toml:: to_string ( self ) . expect ( "Could not encode TOML value" )
93+ }
94+
95+ /// Encodes the configuration to JSON.
96+ ///
97+ /// # Panics
98+ ///
99+ /// Will panic if it can't be converted to JSON.
100+ #[ must_use]
101+ pub fn to_json ( & self ) -> String {
102+ serde_json:: to_string_pretty ( self ) . expect ( "Could not encode JSON value" )
103+ }
84104}
85105
86106impl Validator for Settings {
You can’t perform that action at this time.
0 commit comments