//! DarkRoom desktop entry point. //! //! darkroom-desktop ... use std::path::PathBuf; use dr_plat::diagnostics::Installed; fn main() -> anyhow::Result<()> { // Built rather than `init`ed, so the same logger can be handed to the // diagnostics tee: `env_logger` keeps writing to stderr exactly as before, // and every record it accepts is also appended to the on-disk log // (NFR-OPS-1). `filter()` is asked afterwards because the environment may // have overridden the default below, and the file must not be quieter than // the terminal. let console = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or( "info,wgpu_core=warn,wgpu_hal=warn,zbus=warn,tracing=warn,calloop=warn,rawler=warn", )) .build(); let level = console.filter(); let logging = dr_plat::diagnostics::install(Box::new(console), level); log::info!("DarkRoom v{}", env!("CARGO_PKG_VERSION")); // First thing in the file, so a user asked for "the log" can find it // without being told a path over the phone. match &logging { Installed::ToFile(path) => log::info!("logging to {}", path.display()), Installed::ConsoleOnly(why) => log::warn!("no log file this session: {why}"), } let paths: Vec = std::env::args().skip(1).map(PathBuf::from).collect(); if paths.is_empty() { eprintln!("usage: darkroom-desktop ..."); } dr_ui::run(paths)?; // Skip Rust's normal static/thread-local teardown on the way out: a // background zbus/keyring connection opened by dr_ui::launch_ui can // still be alive here, and unwinding through it races its async-io // reactor thread, panicking with "thread local ... during or after // destruction" when the window is closed. std::process::exit(0); }