crashy

Crates.iocrashy
lib.rscrashy
version0.4.0
created_at2023-12-10 22:01:15.669336+00
updated_at2025-03-28 15:18:20.24119+00
descriptioncrash reporting with nicer stack traces and information about the current process, with optional Sentry integration
homepagehttps://www.bitpowder.com/libs/indigo/
repositoryhttps://gitlab.com/bitpowder/indigo-ng
max_upload_size
id1064553
size86,985
Bernard van Gastel (bvgastel)

documentation

README

crashy

A small crash library that prints that either:

  • prints nicer colored crash traces (that are readable, and contain information like command line arguments), or
  • sends the crash data to sentry (but with minimal dependencies).

Additional it adjusts the console log format to systemd format, so that log severity levels are recognized and the time is omitted (as time is already included in systemd).

It aims to be a small library that covers most (but not all) crash reporting. It reports also the OpenTelemetry TraceId and SpandId if available and the feature trace is enabled.

To set up crashy, in your main function, add:

let _crash_handler = crashy::setup_crashy(); // do not rename variable to `_` as this will affect the lifetime

To use the Sentry integration, enable feature sentry and define the environment variable SENTRY_DSN during building (using env SENTRY_DSN=https://... cargo build), and adjust the set up to one of these two functions:

Sentry integration sync version (will spawn a new thread to transmit the crash report):

let crashy_options = crashy::CrashyOptions::default_sync();
let _crash_handler = crashy::setup_crashy_with_options(crashy_options);

Sentry integration async version with Tokio (will spawn a new Tokio task to transmit the crash report):

let _crash_handler = crashy::setup_crashy_with_options(crashy_options);
let crashy_options = crashy::CrashyOptions::default_async(tokio::runtime::Handle::current());

To get nicer stacktraces, compile to remap paths in the stacktrace to more readable versions. Do this with env RUSTFLAGS=--remap-path-prefix=pwd/= cargo build

Features:

  • sentry to enable Sentry upload (SENTRY_DSN environment variable during build is also needed, see above);
  • trace to enable reporting of OpenTelemetry tracing and span ids.
Commit count: 1754

cargo fmt