diff --git a/CHANGELOG.md b/CHANGELOG.md index 6654e401..5442bc6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` 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 diff --git a/sentry-log/src/lib.rs b/sentry-log/src/lib.rs index 2c2d56c5..a01e8479 100644 --- a/sentry-log/src/lib.rs +++ b/sentry-log/src/lib.rs @@ -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 //! diff --git a/sentry-log/src/logger.rs b/sentry-log/src/logger.rs index 0b5177d1..f6cabd2a 100644 --- a/sentry-log/src/logger.rs +++ b/sentry-log/src/logger.rs @@ -52,7 +52,13 @@ impl From for Vec { /// `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, }