summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs43
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(())
+}