Created
June 27, 2019 10:45
-
-
Save fry/1b8e3164c87e9e41d9e0a220cb4144d9 to your computer and use it in GitHub Desktop.
Sentry Setup in Dynamic Libraries
This file contains hidden or 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
lazy_static! { | |
static ref GUARD: Mutex<Option<sentry::internals::ClientInitGuard>> = Mutex::new(None); | |
} | |
*GUARD.lock().unwrap() = Some(sentry::init(dotenv!("SENTRY_DSN"))); | |
sentry::integrations::panic::register_panic_handler(); | |
let next = panic::take_hook(); | |
panic::set_hook(Box::new(move |info| { | |
next(info); | |
// Dropping the guard here ensures Sentry actually finishes sending the report | |
let _guard = GUARD.lock().unwrap().take(); | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment