Skip to content

Commit

Permalink
Display captured backtrace when available (#2504)
Browse files Browse the repository at this point in the history
* Display captured backtrace when available

* Helpful log message
  • Loading branch information
matheus-consoli committed Jun 4, 2024
1 parent ef1be19 commit 76bb317
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/desktop/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
10 changes: 8 additions & 2 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}"),
Expand All @@ -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);
}
Expand Down

0 comments on commit 76bb317

Please sign in to comment.