diff --git a/src/admin/debug/commands.rs b/src/admin/debug/commands.rs index 5fd0360d99634a6e4d8b552baf4045b13c24bd9a..a50874678b0c11475ff6f6abba15ddf8589fc838 100644 --- a/src/admin/debug/commands.rs +++ b/src/admin/debug/commands.rs @@ -314,6 +314,8 @@ pub(super) async fn force_device_list_updates(_body: Vec<&str>) -> Result<RoomMe pub(super) async fn change_log_level( _body: Vec<&str>, filter: Option<String>, reset: bool, ) -> Result<RoomMessageEventContent> { + let handles = &["console"]; + if reset { let old_filter_layer = match EnvFilter::try_new(&services().globals.config.log) { Ok(s) => s, @@ -324,7 +326,12 @@ pub(super) async fn change_log_level( }, }; - match services().server.log.reload.reload(&old_filter_layer) { + match services() + .server + .log + .reload + .reload(&old_filter_layer, Some(handles)) + { Ok(()) => { return Ok(RoomMessageEventContent::text_plain(format!( "Successfully changed log level back to config value {}", @@ -349,7 +356,12 @@ pub(super) async fn change_log_level( }, }; - match services().server.log.reload.reload(&new_filter_layer) { + match services() + .server + .log + .reload + .reload(&new_filter_layer, Some(handles)) + { Ok(()) => { return Ok(RoomMessageEventContent::text_plain("Successfully changed log level")); }, diff --git a/src/core/log/reload.rs b/src/core/log/reload.rs index cfed785d8cf56824dafe11adea1846c59a1a7a1e..0b72d78718d4922517180b0185d08f4a541d7737 100644 --- a/src/core/log/reload.rs +++ b/src/core/log/reload.rs @@ -45,12 +45,13 @@ pub fn add(&self, name: &str, handle: Handle) { .insert(name.into(), handle); } - pub fn reload(&self, new_value: &EnvFilter) -> Result<()> { + pub fn reload(&self, new_value: &EnvFilter, names: Option<&[&str]>) -> Result<()> { self.handles .lock() .expect("locked") - .values() - .for_each(|handle| { + .iter() + .filter(|(name, _)| names.map_or(false, |names| names.contains(&name.as_str()))) + .for_each(|(_, handle)| { _ = handle.reload(new_value.clone()).or_else(error::else_log); }); diff --git a/src/core/log/suppress.rs b/src/core/log/suppress.rs index 6e883086dd2638a440627e8521f7396d93cf2da5..ca2d54854bfd27c83ba17448be9ef5643dfad707 100644 --- a/src/core/log/suppress.rs +++ b/src/core/log/suppress.rs @@ -18,7 +18,7 @@ fn from_filters(server: &Arc<Server>, restore: EnvFilter, suppress: &EnvFilter) server .log .reload - .reload(suppress) + .reload(suppress, Some(&["console"])) .expect("log filter reloaded"); Self { server: server.clone(), @@ -32,7 +32,7 @@ fn drop(&mut self) { self.server .log .reload - .reload(&self.restore) + .reload(&self.restore, Some(&["console"])) .expect("log filter reloaded"); } } diff --git a/src/main/tracing.rs b/src/main/tracing.rs index 4c8fde5a20915e168286bf4f22f75cda0d45dfcd..78c35c662fe9fe48b0facd2ad545e0c7331394f1 100644 --- a/src/main/tracing.rs +++ b/src/main/tracing.rs @@ -27,7 +27,7 @@ pub(crate) fn init(config: &Config) -> (LogLevelReloadHandles, TracingFlameGuard }; let (fmt_reload_filter, fmt_reload_handle) = reload::Layer::new(filter_layer.clone()); - reload_handles.add("format", Box::new(fmt_reload_handle)); + reload_handles.add("console", Box::new(fmt_reload_handle)); let subscriber = Registry::default().with(fmt_layer.with_filter(fmt_reload_filter));