Skip to content

Commit

Permalink
fix default capture EnvFilter in release mode
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Volk <jason@zemos.net>
  • Loading branch information
jevolk committed Aug 31, 2024
1 parent 7b85235 commit 14b9511
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/admin/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use conduit::{
},
trace,
utils::string::{collect_stream, common_prefix},
Error, Result,
warn, Error, Result,
};
use futures_util::future::FutureExt;
use ruma::{
Expand Down Expand Up @@ -114,7 +114,15 @@ async fn process(context: &Command<'_>, command: AdminCommand, args: &[String])

fn capture_create(context: &Command<'_>) -> (Arc<Capture>, Arc<Mutex<String>>) {
let env_config = &context.services.server.config.admin_log_capture;
let env_filter = EnvFilter::try_new(env_config).unwrap_or_else(|_| "debug".into());
let env_filter = EnvFilter::try_new(env_config).unwrap_or_else(|e| {
warn!("admin_log_capture filter invalid: {e:?}");
cfg!(debug_assertions)
.then_some("debug")
.or(Some("info"))
.map(Into::into)
.expect("default capture EnvFilter")
});

let log_level = env_filter
.max_level_hint()
.and_then(LevelFilter::into_level)
Expand Down
7 changes: 6 additions & 1 deletion src/core/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,11 @@ fn default_sentry_filter() -> String { "info".to_owned() }

fn default_startup_netburst_keep() -> i64 { 50 }

fn default_admin_log_capture() -> String { "debug".to_owned() }
fn default_admin_log_capture() -> String {
cfg!(debug_assertions)
.then_some("debug")
.unwrap_or("info")
.to_owned()
}

fn default_admin_room_tag() -> String { "m.server_notice".to_owned() }

0 comments on commit 14b9511

Please sign in to comment.