Function tracing_panic::panic_hook

source ·
pub fn panic_hook(panic_info: &PanicInfo<'_>)
Expand description

A panic hook that emits an error-level tracing event when a panic occurs.

The default panic hook prints the panic information to stderr, which might or might not be picked up by your telemetry system.

This hook, instead, makes sure that panic information goes through the tracing pipeline you’ve configured.

Usage

use tracing_panic::panic_hook;

fn main() {
    // Initialize your `tracing` subscriber however you like.
    // [...]
    // Then set the panic hook.
    // This should be done only once, at the beginning of your program.
    std::panic::set_hook(Box::new(panic_hook));
}

Backtrace

The hook currently doesn’t try to capture a backtrace.