Skip to content

Commit

Permalink
update api
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf committed May 12, 2024
1 parent 99aea12 commit 9457233
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use vleue_sentry::sentry_panic_reporter;
fn main() {
App::new()
.add_plugins(DefaultPlugins.set(LogPlugin {
update_subscriber: Some(sentry_panic_reporter),
custom_layer: sentry_panic_reporter,
..default()
}));
}
Expand Down
34 changes: 17 additions & 17 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub use bevy::{
layer::{self, SubscriberExt},
Layer,
},
BoxedSubscriber,
BoxedLayer,
},
utils::tracing::{Event, Level, Subscriber},
};
Expand All @@ -36,7 +36,7 @@ pub use bevy_log::{
layer::{self, SubscriberExt},
Layer,
},
BoxedSubscriber, Level,
BoxedLayer, Level,
};
#[cfg(feature = "subcrates")]
#[doc(hidden)]
Expand Down Expand Up @@ -89,11 +89,11 @@ impl<S: Subscriber> Layer<S> for SentryLayer {
///
/// App::new()
/// .add_plugins(DefaultPlugins.set(LogPlugin {
/// update_subscriber: Some(sentry_panic_reporter),
/// custom_layer: sentry_panic_reporter,
/// ..default()
/// }));
/// ```
pub fn sentry_panic_reporter(_: &mut App, subscriber: BoxedSubscriber) -> BoxedSubscriber {
pub fn sentry_panic_reporter(_: &mut App) -> Option<BoxedLayer> {
if let Ok(sentry_dsn) = env::var("SENTRY_DSN") {
let guard = init((
sentry_dsn,
Expand All @@ -114,12 +114,12 @@ pub fn sentry_panic_reporter(_: &mut App, subscriber: BoxedSubscriber) -> BoxedS
})
});

Box::new(subscriber.with(SentryLayer {
Some(Box::new(SentryLayer {
guard,
report_only_panic: true,
}))
} else {
subscriber
None
}
}

Expand All @@ -133,11 +133,11 @@ pub fn sentry_panic_reporter(_: &mut App, subscriber: BoxedSubscriber) -> BoxedS
///
/// App::new()
/// .add_plugins(DefaultPlugins.set(LogPlugin {
/// update_subscriber: Some(sentry_error_reporter),
/// custom_layer: sentry_error_reporter,
/// ..default()
/// }));
/// ```
pub fn sentry_error_reporter(_: &mut App, subscriber: BoxedSubscriber) -> BoxedSubscriber {
pub fn sentry_error_reporter(_: &mut App) -> Option<BoxedLayer> {
if let Ok(sentry_dsn) = env::var("SENTRY_DSN") {
let guard = init((
sentry_dsn,
Expand All @@ -158,12 +158,12 @@ pub fn sentry_error_reporter(_: &mut App, subscriber: BoxedSubscriber) -> BoxedS
})
});

Box::new(subscriber.with(SentryLayer {
Some(Box::new(SentryLayer {
guard,
report_only_panic: false,
}))
} else {
subscriber
None
}
}

Expand All @@ -182,14 +182,14 @@ pub use sentry::{configure_scope, init, ClientOptions};
///
/// App::new()
/// .add_plugins(DefaultPlugins.set(LogPlugin {
/// update_subscriber: Some(sentry_reporter!(true)),
/// custom_layer: sentry_reporter!(true),
/// ..default()
/// }));
/// ```
#[macro_export]
macro_rules! sentry_reporter {
($report_only_panic:literal) => {
|_app: &mut vleue_sentry::App, subscriber: vleue_sentry::BoxedSubscriber| {
|_app: &mut vleue_sentry::App| {
if let Ok(sentry_dsn) = std::env::var("SENTRY_DSN") {
let guard = vleue_sentry::init((
sentry_dsn,
Expand Down Expand Up @@ -217,12 +217,12 @@ macro_rules! sentry_reporter {
})
});

Box::new(vleue_sentry::SubscriberExt::with(
subscriber,
vleue_sentry::SentryLayer::new(guard, $report_only_panic),
))
Some(Box::new(vleue_sentry::SentryLayer::new(
guard,
$report_only_panic,
)))
} else {
subscriber
None
}
}
};
Expand Down

0 comments on commit 9457233

Please sign in to comment.