Skip to content

Commit 8af23ee

Browse files
authored
ref(log): send logs by default when logs feature flag is enabled (#915)
1 parent 3b78cf8 commit 8af23ee

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
- It's now possible to map a `log` record to multiple items in Sentry by combining multiple log filters in the filter, e.g. `log::Level::ERROR => LogFilter::Event | LogFilter::Log`.
1010
- If using a custom `mapper` instead, it's possible to return a `Vec<sentry::integrations::log::RecordMapping>` to map a `log` record to multiple items in Sentry.
1111

12+
### Behavioral changes
13+
14+
- ref(log): send logs by default when logs feature flag is enabled ([#915](https://github.com/getsentry/sentry-rust/pull/915))
15+
- If the `logs` feature flag is enabled, the default Sentry `log` logger now sends logs for all events at or above INFO.
16+
1217
## 0.43.0
1318

1419
### Breaking changes

sentry-log/src/lib.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,10 @@
1111
//! - Records can be captured as traditional [logs](https://docs.sentry.io/product/explore/logs/)
1212
//! Logs can be viewed and queried in the Logs explorer.
1313
//!
14-
//! By default anything above `Info` is recorded as a breadcrumb and
15-
//! anything above `Error` is captured as error event.
16-
//!
17-
//! To capture records as Sentry logs:
18-
//! 1. Enable the `logs` feature of the `sentry` crate.
19-
//! 2. Initialize the SDK with `enable_logs: true` in your client options.
20-
//! 3. Set up a custom filter (see below) to map records to logs (`LogFilter::Log`) based on criteria such as severity.
14+
//! By default anything at or above `Info` is recorded as a breadcrumb and
15+
//! anything at or above `Error` is captured as error event.
16+
//! Additionally, if the `sentry` crate is used with the `logs` feature flag, anything at or above `Info`
17+
//! is captured as a [Structured Log](https://docs.sentry.io/product/explore/logs/).
2118
//!
2219
//! # Examples
2320
//!

sentry-log/src/logger.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ impl From<RecordMapping> for Vec<RecordMapping> {
5252
/// `warning` and `info`, and `debug` and `trace` logs are ignored.
5353
pub fn default_filter(metadata: &log::Metadata) -> LogFilter {
5454
match metadata.level() {
55+
#[cfg(feature = "logs")]
56+
log::Level::Error => LogFilter::Exception | LogFilter::Log,
57+
#[cfg(not(feature = "logs"))]
5558
log::Level::Error => LogFilter::Exception,
59+
#[cfg(feature = "logs")]
60+
log::Level::Warn | log::Level::Info => LogFilter::Breadcrumb | LogFilter::Log,
61+
#[cfg(not(feature = "logs"))]
5662
log::Level::Warn | log::Level::Info => LogFilter::Breadcrumb,
5763
log::Level::Debug | log::Level::Trace => LogFilter::Ignore,
5864
}

0 commit comments

Comments
 (0)