add panic hook for crash debugging
- SHA
cf796ee59e7e02597cff30b17abc887a6857c47b- Parents
-
83761a0 - Tree
694b41f
cf796ee
cf796ee59e7e02597cff30b17abc887a6857c47b83761a0
694b41f| Status | File | + | - |
|---|---|---|---|
| M |
garchomp/src/main.rs
|
10 | 0 |
garchomp/src/main.rsmodified@@ -44,6 +44,16 @@ async fn main() -> Result<()> { | ||
| 44 | 44 | // Initialize logging |
| 45 | 45 | init_logging(cli.verbose); |
| 46 | 46 | |
| 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 | + | |
| 47 | 57 | tracing::info!("garchomp compositor starting"); |
| 48 | 58 | |
| 49 | 59 | // Set up signal handling |