Yet another Honeybadger notifier for Rust
MIT License
Honeybadger is an error-tracking service run by Honeybadger Industries LLC.
mightybadger-rs
is an unofficial Honeybadger notifier for Rust, which hooks into panics and error responses, collects related information, and sends reports to the Honeybadger API server.
In addition to standalone configuration, it provides middlewares for Rocket, Gotham, and Actix Web.
[dependencies]
mightybadger = { git = "https://github.com/qnighy/mightybadger-rs.git", rev = "da98547" }
extern crate mightybadger;
use std::fs::File;
fn main() {
mightybadger::setup();
match File::open("quux.quux") {
Ok(_) => eprintln!("quux.quux exists."),
Err(e) => mightybadger::notify(&e),
};
panic!("test panic");
}
HONEYBADGER_API_KEY=your_own_api_key cargo run
[dependencies]
mightybadger = { git = "https://github.com/qnighy/mightybadger-rs.git", rev = "da98547" }
mightybadger-rocket = { git = "https://github.com/qnighy/mightybadger-rocket.git", rev = "da98547" }
extern crate mightybadger;
extern crate mightybadger_rocket;
...
fn main() {
mightybadger::setup();
rocket::ignite()
...
.attach(mightybadger_rocket::HoneybadgerHook::new())
.launch();
}
[dependencies]
mightybadger = { git = "https://github.com/qnighy/mightybadger-rs.git", rev = "da98547" }
mightybadger-gotham = { git = "https://github.com/qnighy/mightybadger-gotham.git", rev = "da98547" }
extern crate mightybadger;
extern crate mightybadger_gotham;
...
fn router() -> Router {
let (chain, pipelines) = single_pipeline(
new_pipeline()
.add(mightybadger_gotham::HoneybadgerMiddleware)
.build(),
);
build_router(chain, pipelines, |route| { ... })
}
...
fn main() {
mightybadger::setup();
gotham::start(..., router())
}
[dependencies]
mightybadger = { git = "https://github.com/qnighy/mightybadger-rs.git", rev = "da98547" }
mightybadger-actix-web = { git = "https://github.com/qnighy/mightybadger-actix-web.git", rev = "da98547" }
extern crate mightybadger;
extern crate mightybadger_actix_web;
...
fn main() {
mightybadger::setup();
server::new(|| {
App::new()
.middleware(mightybadger_actiX_web::HoneybadgerMiddleware::new())
..
}).bind(..)
.unwrap()
.run();
}
It automatically reads the following environment variables at mightybadger::setup()
:
HONEYBADGER_API_KEY
HONEYBADGER_ENV
HONEYBADGER_REPORT_DATA
HONEYBADGER_ROOT
HONEYBADGER_REVISION
HONEYBADGER_HOSTNAME
Moreover, you can programmatically configure the Honeybadger client as follows:
fn main() {
mightybadger::setup();
mightybadger::configure(|config| {
if config.api_key.is_none() {
config.api_key = Some("abcd1234".to_string());
}
config.env = Some("production".to_string());
config.report_data = Some(true);
config.root = Some("/home/ubuntu/app".to_string());
config.revision = Some("0123456789abcdef0123456789abcdef01234567".to_string());
config.hostname = Some("api.example.com".to_string());
config.request.filter_keys = Some(vec![
"password".to_string(),
"HTTP_AUTHORIZATION".to_string(),
"passcode".to_string(),
]);
});
}
Note: it's still in its early stage and the Rust API is subject to change. I strongly recommend you to insert rev = ".."
attribute in the dependencies to prevent breakage.
/proc
MIT License