From d916021179f287d834b7899bb42c632f813b1174 Mon Sep 17 00:00:00 2001 From: kernelkind Date: Thu, 6 Feb 2025 16:36:13 -0500 Subject: [PATCH] fix file logging closes: https://github.com/damus-io/notedeck/issues/572 Signed-off-by: kernelkind --- crates/notedeck_chrome/src/notedeck.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/notedeck_chrome/src/notedeck.rs b/crates/notedeck_chrome/src/notedeck.rs index d9b3894c..a48207b6 100644 --- a/crates/notedeck_chrome/src/notedeck.rs +++ b/crates/notedeck_chrome/src/notedeck.rs @@ -4,13 +4,14 @@ use notedeck_chrome::setup::{generate_native_options, setup_chrome}; use notedeck::{DataPath, DataPathType, Notedeck}; use notedeck_columns::Damus; +use tracing_appender::non_blocking::WorkerGuard; use tracing_subscriber::EnvFilter; // Entry point for wasm //#[cfg(target_arch = "wasm32")] //use wasm_bindgen::prelude::*; -fn setup_logging(path: &DataPath) { +fn setup_logging(path: &DataPath) -> Option { #[allow(unused_variables)] // need guard to live for lifetime of program let (maybe_non_blocking, maybe_guard) = { let log_path = path.path(DataPathType::Log); @@ -57,6 +58,8 @@ fn setup_logging(path: &DataPath) { .with_env_filter(EnvFilter::from_default_env()) .init(); } + + maybe_guard } // Desktop @@ -66,7 +69,8 @@ async fn main() { let base_path = DataPath::default_base_or_cwd(); let path = DataPath::new(base_path.clone()); - setup_logging(&path); + // This guard must be scoped for the duration of the entire program so all logs will be written + let _guard = setup_logging(&path); let _res = eframe::run_native( "Damus Notedeck",