From 9ab4c266523faa170c00f28cab43b91137a3f531 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 6 Jul 2026 22:55:07 +0200 Subject: fix: only configure logging on debug builds --- src/main.rs | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 667ac62..3a44d40 100644 --- a/src/main.rs +++ b/src/main.rs @@ -53,22 +53,7 @@ const RESOURCE_DIR: &str = "res"; fn main() -> Result<(), EngineError> { - #[cfg(windows)] - nu_ansi_term::enable_ansi_support() - .map_err(EngineError::from_system_defined_win32_error) - .with_context(|| "Failed to enable ANSI support")?; - - tracing_subscriber::registry() - .with( - tracing_subscriber::fmt::layer() - .with_timer(ChronoLocal::new("%T%.6f".to_string())), - ) - .with( - EnvFilter::builder() - .with_default_directive(LevelFilter::DEBUG.into()) - .from_env()?, - ) - .init(); + configure_logging()?; Engine::new() .with_extension(engine::windowing::Extension::default()) @@ -171,3 +156,29 @@ fn init(mut assets: Single, mut actions: Actions) -> Result<(), EngineEr Ok(()) } + +fn configure_logging() -> Result<(), EngineError> +{ + if !cfg!(debug_assertions) { + return Ok(()); + } + + #[cfg(windows)] + nu_ansi_term::enable_ansi_support() + .map_err(EngineError::from_system_defined_win32_error) + .with_context(|| "Failed to enable ANSI support")?; + + tracing_subscriber::registry() + .with( + tracing_subscriber::fmt::layer() + .with_timer(ChronoLocal::new("%T%.6f".to_string())), + ) + .with( + EnvFilter::builder() + .with_default_directive(LevelFilter::DEBUG.into()) + .from_env()?, + ) + .init(); + + Ok(()) +} -- cgit v1.2.3-18-g5258