/// Register a panic hook that prints the panic payload to the logger before running the
/// default panic hook.
Register a panic hook that prints the panic payload to the logger before running the
default panic hook.
Register a panic hook that prints the panic payload to the logger before running the default panic hook .
pub fn install_panic_hook() {
        let default_hook = panic::take_hook();
        panic::set_hook(Box::new(move |panic_info| {
            // Handle common cases of &'static str or String payload.
            let msg = match panic_info.payload().downcast_ref::<&'static str>() {
                    Some(s) => *s,
                    None => match panic_info.payload().downcast_ref::<String>() {
                        Some(s) => &s[..],
                        None => "<Unknown panic payload type>",
                    }
                };
            LOGGER.log_helper("PANIC", &format_args!("{}", msg));
            default_hook(panic_info);
        }));
    }
pub fn install_panic_hook ( ) { let default_hook = panic :: take_hook ( ) ; panic :: set_hook ( Box :: new ( move | panic_info | { // Handle common cases of &'static str or String payload. let msg = match panic_info . payload ( ) . downcast_ref :: < & ' static str > ( ) { Some ( s ) => * s , None => match panic_info . payload ( ) . downcast_ref :: < String > ( ) { Some ( s ) => & s [ .. ] , None => " " , } } ; LOGGER . log_helper ( " " , & format_args ! ( " " msg ) ) ; default_hook ( panic_info ) ; } ) ) ; }
Register a panic hook that prints the panic payload to the logger before running the
default panic hook.
Register a panic hook that prints the panic payload to the logger before running the default panic hook .