Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
- 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`.
- 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.

### Behavioral changes

- ref(log): send logs by default when logs feature flag is enabled ([#915](https://github.com/getsentry/sentry-rust/pull/915))
- If the `logs` feature flag is enabled, the default Sentry `log` logger now sends logs for all events at or above INFO.

## 0.43.0

### Breaking changes
Expand Down
11 changes: 4 additions & 7 deletions sentry-log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@
//! - Records can be captured as traditional [logs](https://docs.sentry.io/product/explore/logs/)
//! Logs can be viewed and queried in the Logs explorer.
//!
//! By default anything above `Info` is recorded as a breadcrumb and
//! anything above `Error` is captured as error event.
//!
//! To capture records as Sentry logs:
//! 1. Enable the `logs` feature of the `sentry` crate.
//! 2. Initialize the SDK with `enable_logs: true` in your client options.
//! 3. Set up a custom filter (see below) to map records to logs (`LogFilter::Log`) based on criteria such as severity.
//! By default anything at or above `Info` is recorded as a breadcrumb and
//! anything at or above `Error` is captured as error event.
//! Additionally, if the `sentry` crate is used with the `logs` feature flag, anything at or above `Info`
//! is captured as a [Structured Log](https://docs.sentry.io/product/explore/logs/).
//!
//! # Examples
//!
Expand Down
6 changes: 6 additions & 0 deletions sentry-log/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ impl From<RecordMapping> for Vec<RecordMapping> {
/// `warning` and `info`, and `debug` and `trace` logs are ignored.
pub fn default_filter(metadata: &log::Metadata) -> LogFilter {
match metadata.level() {
#[cfg(feature = "logs")]
log::Level::Error => LogFilter::Exception | LogFilter::Log,
#[cfg(not(feature = "logs"))]
log::Level::Error => LogFilter::Exception,
#[cfg(feature = "logs")]
log::Level::Warn | log::Level::Info => LogFilter::Breadcrumb | LogFilter::Log,
#[cfg(not(feature = "logs"))]
log::Level::Warn | log::Level::Info => LogFilter::Breadcrumb,
log::Level::Debug | log::Level::Trace => LogFilter::Ignore,
}
Expand Down