pub fn install_panic_recorder(handle: RecorderHandle, path: impl Into<PathBuf>)Expand description
Installs a panic hook that saves whatever handle’s recorder has captured so far to path
when the process panics, then chains to whatever hook was already installed.
The saved recording is exactly what a bug report needs: the input stream leading up to the
crash, ready to hand to TestHarness::replay
or replay_live as a regression test, with no hand-transcription.
Chaining to the previous hook (rather than replacing it) is deliberate: this must never
suppress the panic message itself, or any other diagnostic (e.g. color-backtrace,
console_error_panic_hook) a consumer already installed. The save happens first, so a panic
while saving (a full disk, a bad path) still lets the original panic’s own output reach
the terminal via the chained hook, rather than replacing it with a save failure.
This installs no hotkey and has no opinion on what triggers a save beyond an actual panic:
deliberate, so it can never collide with a consumer’s own keybindings. Call
RecorderHandle::save directly wherever a consumer wants a non-panic trigger (a dedicated
debug key, a signal handler, an explicit “report a bug” menu item).
§Examples
use retroglyph_core::backend::Headless;
use retroglyph_recorder::{InputRecorder, install_panic_recorder};
let recorder = InputRecorder::new(Headless::new(80, 24));
install_panic_recorder(recorder.handle(), "crash.rgrec");