Display captured backtrace when available (#2504)

* Display captured backtrace when available

* Helpful log message
This commit is contained in:
Consoli 2024-06-04 11:22:30 -03:00 committed by GitHub
parent ef1be196c1
commit 76bb317201
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View file

@ -260,7 +260,7 @@ async fn main() -> tauri::Result<()> {
handle.windows().iter().for_each(|(_, window)| {
if should_clear_localstorage {
println!("bruh?");
println!("cleaning localStorage");
for webview in window.webviews() {
webview.eval("localStorage.clear();").ok();
}

View file

@ -212,8 +212,6 @@ impl Node {
"info"
};
// let level = "debug"; // Exists for now to debug the location manager
std::env::set_var(
"RUST_LOG",
format!("info,sd_core={level},sd_p2p=debug,sd_core::location::manager=info,sd_ai={level}"),
@ -239,12 +237,20 @@ impl Node {
.init();
std::panic::set_hook(Box::new(move |panic| {
use std::backtrace::{Backtrace, BacktraceStatus};
let backtrace = Backtrace::capture();
if let Some(location) = panic.location() {
tracing::error!(
message = %panic,
panic.file = format!("{}:{}", location.file(), location.line()),
panic.column = location.column(),
);
if backtrace.status() == BacktraceStatus::Captured {
// NOTE(matheus-consoli): it seems that `tauri` is messing up the stack-trace
// and it doesn't capture anything, even when `RUST_BACKTRACE=full`,
// so in the current architecture, this is emitting an empty event.
tracing::error!(message = %backtrace);
}
} else {
tracing::error!(message = %panic);
}