By adding panic hook that logs the panic and then return to the default panic handler would be useful for debugging when users who manage to crash the application require assistance. This could possibly be implemented as bellow
use std::panic;
use log::*;
let default_panic = panic::take_hook()
panic::set_hook(Box::new(|info| {
error!("{}",info);
default_panic(info);
}));
Its behavior can be updated to open the log file on panic, might be useful if its distributed as a gui application.
The opener crate open a file with the os default application https://docs.rs/opener/latest/opener/fn.open.html#
use std::panic;
use log::*;
use opener::open;
let default_panic = panic::take_hook()
panic::set_hook(Box::new(|info| {
error!("{}",info);
open("../output.log");
default_panic(info);
}));
By adding panic hook that logs the panic and then return to the default panic handler would be useful for debugging when users who manage to crash the application require assistance. This could possibly be implemented as bellow
Its behavior can be updated to open the log file on panic, might be useful if its distributed as a gui application.
The opener crate open a file with the os default application https://docs.rs/opener/latest/opener/fn.open.html#