From f7753ece129c55fdc2c43be13380522fdc3f11f3 Mon Sep 17 00:00:00 2001 From: Jonas Berlin Date: Mon, 4 Nov 2024 00:31:55 +0200 Subject: [PATCH] fix: Also report toml loading failures with --watch * hot_reload crate (used for loading config.toml) does not report the ReloaderError we give, only that reloading failed with generic message "Failed to reload watch target" in WARN level * .. but WARN level of external crates are not logged by default => no log message when broken config and --watch is active * => report our own log message more in line with non-watch mode and with detail about why loading failed --- rpxy-bin/src/config/service.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rpxy-bin/src/config/service.rs b/rpxy-bin/src/config/service.rs index 8769b968..d5bc1295 100644 --- a/rpxy-bin/src/config/service.rs +++ b/rpxy-bin/src/config/service.rs @@ -1,6 +1,7 @@ use super::toml::ConfigToml; use async_trait::async_trait; use hot_reload::{Reload, ReloaderError}; +use tracing::warn; #[derive(Clone)] pub struct ConfigTomlReloader { @@ -17,8 +18,10 @@ impl Reload for ConfigTomlReloader { } async fn reload(&self) -> Result, ReloaderError> { - let conf = ConfigToml::new(&self.config_path) - .map_err(|_e| ReloaderError::::Reload("Failed to reload config toml"))?; + let conf = ConfigToml::new(&self.config_path).map_err(|e| { + warn!("Invalid toml file: {e:?}"); + ReloaderError::::Reload("Failed to reload config toml") + })?; Ok(Some(conf)) } }