Skip to content

Commit 6f88049

Browse files
mixalturekmitsuhiko
authored andcommitted
feat: add configuration to disable expensive computations of stacktraces. (#128)
1 parent 6c84e2a commit 6f88049

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/integrations/log.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,15 @@ pub struct LoggerOptions {
4141
pub global_filter: Option<log::LevelFilter>,
4242
/// The sentry specific log level filter (defaults to `Info`)
4343
pub filter: log::LevelFilter,
44-
/// If set to `true`, breadcrumbs are emitted. (defaults to `true`)
44+
/// If set to `true`, breadcrumbs will be emitted. (defaults to `true`)
4545
pub emit_breadcrumbs: bool,
46-
/// If set to `true` error events are sent for errors in the log. (defaults to `true`)
46+
/// If set to `true` error events will be sent for errors in the log. (defaults to `true`)
4747
pub emit_error_events: bool,
48-
/// If set to `true` warning events are sent for warnings in the log. (defaults to `false`)
48+
/// If set to `true` warning events will be sent for warnings in the log. (defaults to `false`)
4949
pub emit_warning_events: bool,
50+
/// If set to `true` current stacktrace will be resolved and attached
51+
/// to each event. (expensive, defaults to `true`)
52+
pub attach_stacktraces: bool,
5053
}
5154

5255
impl Default for LoggerOptions {
@@ -57,6 +60,7 @@ impl Default for LoggerOptions {
5760
emit_breadcrumbs: true,
5861
emit_error_events: true,
5962
emit_warning_events: false,
63+
attach_stacktraces: true,
6064
}
6165
}
6266
}
@@ -177,7 +181,8 @@ impl log::Log for Logger {
177181

178182
fn log(&self, record: &log::Record<'_>) {
179183
if self.options.create_issue_for_record(record) {
180-
Hub::with_active(|hub| hub.capture_event(event_from_record(record, true)));
184+
Hub::with_active(|hub| hub.capture_event(
185+
event_from_record(record, self.options.attach_stacktraces)));
181186
}
182187
if self.options.emit_breadcrumbs && record.level() <= self.options.filter {
183188
add_breadcrumb(|| breadcrumb_from_record(record))

0 commit comments

Comments
 (0)