Skip to content

Commit

Permalink
panic 時のログをファイルに書き出すようにする(わりと原因不明に落ちることがあるので)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitoma committed Jan 20, 2025
1 parent 047e089 commit a13ca19
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ui_support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ pub async fn run_support(support: SimpleStateSupport) {
console_log::init_with_level(log::Level::Warn).expect("Could't initialize logger");
} else {
env_logger::try_init().unwrap_or_default();
use std::io::Write;
let default_hook = std::panic::take_hook();
std::panic::set_hook(Box::new(move |info| {
let mut file = std::fs::File::create("kashikishi.panic.log").expect("Could not create log file");
writeln!(file, "{}", info).expect("Could not write to log file");
default_hook(info);
}));
}
}
record_start_of_phase("initialize");
Expand Down

0 comments on commit a13ca19

Please sign in to comment.