From 82fdb7b2a2e3fe6597e91d2298722767c5b4450b Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sat, 4 Feb 2023 16:13:09 +0200 Subject: [PATCH] Changed `--debug` behavior to only affect stdout debug/info messages --- src/main.rs | 5 ++--- src/ui/about.rs | 2 +- src/ui/main.rs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4c3aee8..b0ff9d1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,6 +13,7 @@ pub use prettify_bytes::prettify_bytes; pub const APP_ID: &str = "moe.launcher.an-anime-game-launcher-gtk"; pub const APP_VERSION: &str = env!("CARGO_PKG_VERSION"); +pub const APP_DEBUG: bool = cfg!(debug_assertions); /// Sets to `true` when the `App` component is ready (fully initialized) pub static mut READY: bool = false; @@ -24,8 +25,6 @@ pub fn is_ready() -> bool { } lazy_static::lazy_static! { - pub static ref APP_DEBUG: bool = cfg!(debug_assertions) || std::env::args().any(|arg| &arg == "--debug"); - /// Config loaded on the app's start. Use `config::get()` to get up to date config instead. /// This one is used to prepare some launcher UI components on start pub static ref CONFIG: config::Config = config::get().expect("Failed to load config"); @@ -59,7 +58,7 @@ lazy_static::lazy_static! { fn main() { tracing_subscriber::fmt() .with_span_events(tracing_subscriber::fmt::format::FmtSpan::FULL) - .with_max_level(if *APP_DEBUG { + .with_max_level(if APP_DEBUG || std::env::args().any(|arg| &arg == "--debug") { tracing::Level::TRACE } else { tracing::Level::WARN diff --git a/src/ui/about.rs b/src/ui/about.rs index f48eb3f..76f0f25 100644 --- a/src/ui/about.rs +++ b/src/ui/about.rs @@ -36,7 +36,7 @@ impl SimpleComponent for AboutDialog { set_version: &{ // Debug build & build's version doesn't contain any suffix (-dev, -beta, etc) - if *crate::APP_DEBUG && !crate::APP_VERSION.contains('-') { + if crate::APP_DEBUG && !crate::APP_VERSION.contains('-') { format!("{}-dev", crate::APP_VERSION) } diff --git a/src/ui/main.rs b/src/ui/main.rs index d195f5b..6bdbb84 100644 --- a/src/ui/main.rs +++ b/src/ui/main.rs @@ -147,7 +147,7 @@ impl SimpleComponent for App { let widgets = view_output!(); - if *crate::APP_DEBUG { + if crate::APP_DEBUG { widgets.main_window.add_css_class("devel"); }