Created
April 4, 2018 22:20
-
-
Save mitsuhiko/5188b99cea28886adf45c4c9d0295784 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::panic; | |
extern crate sentry; | |
extern crate log; | |
pub struct Logger; | |
impl log::Log for Logger { | |
fn enabled(&self, metadata: &log::Metadata) -> bool { | |
metadata.level() <= log::max_level() | |
} | |
fn log(&self, record: &log::Record) { | |
if self.enabled(record.metadata()) { | |
// this captures a log record to the current context. | |
// If there is an active task it logs to it's context, | |
// otherwise it logs to a thread local thing. | |
sentry::capture_log_record(&record); | |
} | |
} | |
} | |
panic::set_hook(Box::new(|info| { | |
sentry::capture_exception(&info); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment