feat(logs): Enable logs by default#3846
Conversation
Flip SentryOptions.enableLogs default from false to true so logs work out of the box, matching enableMetrics. Logs are only sent when the user emits them - by calling Sentry.logger.* or by explicitly adding a log-emitting integration (LoggingIntegration is the only one and is never auto-registered), so the flip alone sends nothing. Document the opt-in contract on enableLogs and LoggingIntegration, pin the new default with a test, and opt metrics-focused lifecycle tests out of logs explicitly. Fixes GH-3682 Fixes GH-3833 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Features
Fixes
DependenciesDeps
Internal Changes
🤖 This preview updates automatically when you update the PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v10-branch #3846 +/- ##
=============================================
Coverage ? 87.30%
=============================================
Files ? 337
Lines ? 12257
Branches ? 0
=============================================
Hits ? 10701
Misses ? 1556
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
There was a problem hiding this comment.
Pull request overview
This PR changes the core SDK default so SentryOptions.enableLogs is true by default (aligning with enableMetrics), allowing Sentry.logger.* to function without additional configuration while still only sending logs when they are explicitly emitted (via Sentry.logger.*) or via an explicitly added log-emitting integration (e.g. LoggingIntegration from sentry_logging).
Changes:
- Flip
SentryOptions.enableLogsdefault fromfalsetotrueand update its doc comment to clarify the opt-in model. - Clarify
LoggingIntegrationdocs to state that adding the integration is the opt-in for forwardingpackage:loggingrecords as structured Sentry logs (still gated byenableLogs). - Add/adjust tests to reflect the new default and keep unrelated integration tests deterministic.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/dart/lib/src/sentry_options.dart | Sets enableLogs default to true and documents when logs are sent. |
| packages/dart/test/sentry_options_test.dart | Adds coverage asserting enableLogs is true by default. |
| packages/logging/lib/src/logging_integration.dart | Updates docs to clarify opt-in behavior and the enableLogs gating. |
| packages/flutter/test/integrations/load_contexts_integration_test.dart | Explicitly disables logs in metrics-focused tests to avoid log-related lifecycle callback registration affecting expectations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
SentryOptions.enableLogsnow defaults totrue, matchingenableMetrics, so callingSentry.logger.*works without any configuration.Flipping the default sends nothing by itself: logs only flow when the user emits them — by calling
Sentry.logger.*or by explicitly adding a log-emitting integration. Per the develop spec, integrations that auto-emit logs must be opt-in; the audit for #3833 confirmedLoggingIntegration(sentry_logging) is the only such integration in this repo and is never auto-registered, so explicitly adding it is the opt-in and no integration-level toggle is needed. Doc comments onenableLogsandLoggingIntegrationnow spell out that contract.Behavior change for existing users: apps that already add
LoggingIntegration(or callSentry.logger.*) without settingenableLogs = truewill start sending logs after upgrading; settingenableLogs = falserestores the old behavior.Fixes #3682
Fixes #3833