diff options
| author | HampusM <hampus@hampusmat.com> | 2026-07-06 22:55:07 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-07-06 22:55:07 +0200 |
| commit | 9ab4c266523faa170c00f28cab43b91137a3f531 (patch) | |
| tree | 9d02781cdc3e25b0248497f0269ffefd6ba0936d /src/main.rs | |
| parent | b4e8793d7ccea40da275affae00446775fa752ee (diff) | |
fix: only configure logging on debug builds
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 43 |
1 files changed, 27 insertions, 16 deletions
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<Assets>, 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(()) +} |
