gardesk/garchomp / cf796ee

Browse files

add panic hook for crash debugging

Authored by espadonne
SHA
cf796ee59e7e02597cff30b17abc887a6857c47b
Parents
83761a0
Tree
694b41f

1 changed file

StatusFile+-
M garchomp/src/main.rs 10 0
garchomp/src/main.rsmodified
@@ -44,6 +44,16 @@ async fn main() -> Result<()> {
4444
     // Initialize logging
4545
     init_logging(cli.verbose);
4646
 
47
+    // Set panic hook to log panics before exit
48
+    std::panic::set_hook(Box::new(|info| {
49
+        let backtrace = std::backtrace::Backtrace::force_capture();
50
+        tracing::error!("PANIC: {}", info);
51
+        tracing::error!("Backtrace:\n{}", backtrace);
52
+        // Also write to stderr in case tracing isn't working
53
+        eprintln!("PANIC: {}", info);
54
+        eprintln!("Backtrace:\n{}", backtrace);
55
+    }));
56
+
4757
     tracing::info!("garchomp compositor starting");
4858
 
4959
     // Set up signal handling