mirror of
https://github.com/infinilabs/coco-app.git
synced 2025-12-29 00:24:46 +01:00
chore: display backtrace in panic log (#805)
Having backtrace in the panic log will help debugging a lot. Under release builds, we strip our binary so the symbols information is unavailable, but this information is still useful in debug builds. Panic log in release builds: ``` Time: [YYYY-MM-DD-HH-MM-SS] Location: [/Users/foo/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tauri-2.5.1/src/lib.rs:742:7] Message: [state() called before manage() for tauri_plugin_global_shortcut::GlobalShortcut<tauri_runtime_wry::Wry<tauri::EventLoopMessage>>] Backtrace: 0: __mh_execute_header 1: __mh_execute_header 2: __mh_execute_header 3: __mh_execute_header 4: __mh_execute_header 5: __mh_execute_header 6: __mh_execute_header 7: __mh_execute_header 8: __mh_execute_header 9: __mh_execute_header 10: __mh_execute_header 11: __mh_execute_header 12: __mh_execute_header 13: __mh_execute_header 14: __mh_execute_header 15: __mh_execute_header 16: __mh_execute_header 17: <unknown> 18: <unknown> ```
This commit is contained in:
@@ -78,9 +78,13 @@ fn setup_panic_hook() {
|
||||
"Unknown location".to_string()
|
||||
};
|
||||
|
||||
// Use `force_capture()` instead of `capture()` as we want backtrace
|
||||
// regardless of whether the corresponding env vars are set or not.
|
||||
let backtrace = std::backtrace::Backtrace::force_capture();
|
||||
|
||||
let panic_log = format!(
|
||||
"Time: [{}]\nLocation: [{}]\nMessage: [{}]",
|
||||
datetime_str, location, panic_message
|
||||
"Time: [{}]\nLocation: [{}]\nMessage: [{}]\nBacktrace: \n{}",
|
||||
datetime_str, location, panic_message, backtrace
|
||||
);
|
||||
|
||||
// Write to panic file
|
||||
|
||||
Reference in New Issue
Block a user