Move logging config to main configuration file.

- Move the content of what was stored in log4rs.yml into the main config
  file, so that there is just one file to parse to get the complete
  configuration.
- Create the global switch `--home` to pass/overload the value for
  SEQUOIA_HOME in the configuration file.
This commit is contained in:
Malte Meiboom
2026-05-18 11:11:22 +02:00
parent 6611a43a24
commit 14dca91d92
5 changed files with 81 additions and 23 deletions
+6 -9
View File
@@ -1,5 +1,6 @@
//! Husk milter
use anyhow;
use std::process;
use std::sync::{Arc, Mutex};
@@ -18,7 +19,7 @@ use daemon::Daemon;
pub mod common;
#[tokio::main]
async fn main() {
async fn main() -> anyhow::Result<()> {
let args = CliArgs::parse();
let config_file = match &args.config {
@@ -26,7 +27,8 @@ async fn main() {
None => defaults::CONFIG_FILE_LOCATION
};
let husk_config = match HuskConfig::load(config_file) {
// XXX: Improve the way cli parameters are passed into the configuration.
let husk_config = match HuskConfig::load(config_file, args.home.clone()) {
Ok(config) => config,
Err(e) => {
eprintln!("{:?}", e);
@@ -34,14 +36,9 @@ async fn main() {
}
};
log4rs::init_file(husk_config.logfile_config(), Default::default()).unwrap();
log::info!("starting...");
husk_config.init_logging()?;
let config_container: HuskConfigContainer = Arc::new(Mutex::new(husk_config));
if let Err(e) = commands::dispatch(args, config_container).await {
eprintln!("exit with {:?}", e);
// XXX: actually return an error code
}
commands::dispatch(args, config_container).await
}