Skip to content

ewpratten/crashreport-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automatic Crash Reporting for Rust

Crates.io Docs.rs Build Clippy Audit

crashreport is a set & forget crate that appends a button to your application's panic messages allowing users to quickly report basic diagnostic information back to you.

Usage

Firstly, this crate relies on you setting the repository key in your Cargo.toml file. When using crashreport, your Cargo.toml could end up looking something like this:

[package]
name = "my-awesome-crate"
version = "0.1.0"
repository = "https://github.com/ewpratten/my-awesome-crate"

[dependencies]
crashreport = "^1.0.0"

# If you never want terminal colors, import the crate like this instead:
crashreport = { version = "^1.0.0", default-features = false }

On the code side, simply use our crashreport! macro to add a button to your panic messages globally:

#[macro_use]
extern crate crashreport;

pub fn main() {
    // The important bit :)
    crashreport!();

    // ... do stuff

    // Your panics are now a little fancier!
    panic!("This is a panic!");
}

A bit about the internals

crashreport works by appending a new function to the end of whatever your existing panic handler is. Don't worry, you can keep your fancy custom handlers if you want. Just initialize them before calling crashreport!.

Git provider resolution

As of now, we support the following hosted Git services:

  • GitHub
  • GitLab

If you happen to be using a self-hosted version of any of these services, crashreport will not pick it up automatically. Instead, enable one of the following features to force override provider resolution:

  • assume_github
  • assume_gitlab

Enabling more than one of these features will result in the first being used

Terminal URLs

Whenever possible, crashreport will try to make clickable buttons in your terminal. The work of deciding weather the terminal supports this is carried out by the supports-hyperlinks crate. If issues arise, please open an issue over there to add support.

Worst case, you can force-disable button creation (falling back on printing out a URL) by setting FORCE_HYPERLINK=0 in your environment.

Meta crashes

Did you manage to crash crashreport itself? Panics caused inside of panic handlers produce large stacktraces. Just open an issue in this repository with your stack trace, and I will try to help you out.