summaryrefslogtreecommitdiff
path: root/common/rust/src/config.rs
diff options
context:
space:
mode:
authorMatthieu <matthieu@developershouse.xyz>2021-10-12 22:51:30 +0400
committerMatthieu <matthieu@developershouse.xyz>2021-10-12 22:51:30 +0400
commit005dadb342c6a79d154d3eaf5a5fbb86f3a7e641 (patch)
tree8363ea7992b6275e32e019e68678f28bfe40fdb1 /common/rust/src/config.rs
parenta02b25f235ba6eff33c6fd965c97071d5f112b6d (diff)
tests, cleanup & rest base
Diffstat (limited to 'common/rust/src/config.rs')
-rw-r--r--common/rust/src/config.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/common/rust/src/config.rs b/common/rust/src/config.rs
index 3dcd72c..c4ad7b0 100644
--- a/common/rust/src/config.rs
+++ b/common/rust/src/config.rs
@@ -1,5 +1,5 @@
use std::env;
-use config::{Config, ConfigError, Environment, File, Source};
+use config::{Config, ConfigError, Environment, File};
use log::info;
use serde::Deserialize;
@@ -24,6 +24,8 @@ where
/// Initializes a new configuration like the other components of nova
/// And starts the prometheus metrics server if needed.
pub fn new(service_name: &str) -> Result<Settings<T>, ConfigError> {
+ pretty_env_logger::init();
+
let mut default = Config::default();
// this file my be shared with all the components
default.merge(File::with_name("config/default"))?;
@@ -34,17 +36,19 @@ where
default.merge(File::with_name("config/local").required(false))?;
let env = Environment::with_prefix("NOVA").separator("__");
- println!("{:?}", env.collect());
// we can configure each component using environment variables
default.merge(env)?;
let mut config: Settings<T> = default.clone().try_into().unwrap();
// try to load the config
config.config = default.get::<T>(&service_name).unwrap();
- pretty_env_logger::init();
// start the monitoring system if needed
crate::monitoring::start_monitoring(&config.monitoring);
Ok(config)
}
}
+
+pub fn test_init() {
+ pretty_env_logger::init();
+}