Skip to content

backtrace-labs/backtrace-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backtrace error submission crate

Installation

[dependencies]
backtraceio = "0.1"

Usage

Global error handler

Pass your custom token and upload url from your Backtrace account and a report modification closure/function to the backtraceio::register_error_handler function.

backtraceio::register_error_handler(
    "https://UNIVERSE.sp.backtrace.io:6098",
    "YOURTOKEN",
    closure
);

Report modification function

The error handler will pass the Report and std::panic::PanicInfo objects back to the user, in case there are additional attributes/annotations to be defined (described more in detail here). It should accept &mut Report, &PanicInfo, making any changes desired to the report.

Example

use backtraceio::Report;

fn main() {
    backtraceio::register_error_handler(
        "https://UNIVERSE.sp.backtrace.io:6098",
        "YOUR_TOKEN",
        |r: &mut Report, _| {
            let cpus = num_cpus::get();
            let cpus = cpus.to_string();
            r.attributes.insert(String::from("cpu.cores"), cpus);
        },
    );

    println!("Hello, world!");
    panic!("{:?}", 69);
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages