sentry_core/
macros.rs
1#[macro_export]
18macro_rules! release_name {
19 () => {{
20 use std::sync::Once;
21 static mut INIT: Once = Once::new();
22 static mut RELEASE: Option<String> = None;
23 unsafe {
24 INIT.call_once(|| {
25 RELEASE = option_env!("CARGO_PKG_NAME").and_then(|name| {
26 option_env!("CARGO_PKG_VERSION").map(|version| format!("{}@{}", name, version))
27 });
28 });
29 RELEASE.as_ref().map(|x| {
30 let release: &'static str = ::std::mem::transmute(x.as_str());
31 ::std::borrow::Cow::Borrowed(release)
32 })
33 }
34 }};
35}
36
37#[macro_export]
39#[doc(hidden)]
40macro_rules! with_client_impl {
41 ($body:block) => {
42 #[cfg(feature = "client")]
43 {
44 $body
45 }
46 #[cfg(not(feature = "client"))]
47 {
48 Default::default()
49 }
50 };
51}
52
53#[macro_export]
55#[doc(hidden)]
56macro_rules! sentry_debug {
57 ($($arg:tt)*) => {
58 #[cfg(feature = "debug-logs")] {
59 ::log::debug!(target: "sentry", $($arg)*);
60 }
61 #[cfg(not(feature = "debug-logs"))] {
62 $crate::Hub::with(|hub| {
63 if hub.client().map_or(false, |c| c.options().debug) {
64 eprint!("[sentry] ");
65 eprintln!($($arg)*);
66 }
67 });
68 }
69 }
70}
71
72#[allow(unused_macros)]
73macro_rules! minimal_unreachable {
74 () => {
75 panic!(
76 "this code should not be reachable. It's stubbed out for minimal usage. \
77 If you get this error this is a bug in the sentry minimal support"
78 );
79 };
80}