Skip to content

Commit 8eeaffb

Browse files
adinauerclaude
andcommitted
ref(logging): Rename Logs opt-ins
Use state-oriented names for the new Logback, Log4j2, JUL, Timber, Logcat, and Spring Boot Logs controls. Expose get...Enabled accessors so Java-defined options map to natural Kotlin properties before these APIs are released. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent d8b77e7 commit 8eeaffb

56 files changed

Lines changed: 210 additions & 209 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cursor/rules/options.mdc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Allows setting options via `AndroidManifest.xml` `<meta-data>` tags.
7676
- Add a `static final String` constant for the key
7777
- Read it in `applyMetadata()` using `readBool(metadata, logger, CONSTANT, defaultValue)`
7878
- Apply automatic-source options directly, for example
79-
`options.setEnableLogcatLogs(...)` for `io.sentry.logcat.logs.enabled`
79+
`options.setLogcatLogsEnabled(...)` for `io.sentry.logcat.logs.enabled`
8080
- Do not add or restore `io.sentry.logs.enabled` or `io.sentry.metrics.enabled`; those aggregate
8181
keys are obsolete and are read only to emit migration warnings.
8282

@@ -89,8 +89,8 @@ Allows setting options via `AndroidManifest.xml` `<meta-data>` tags.
8989

9090
`SentryProperties` extends `SentryOptions`, so bindable namespaced behavior options are available
9191
through the `SentryOptions` class hierarchy. Spring-owned integration controls belong to a Spring
92-
namespace instead. For example, `SentryProperties.Logging.enableLogs` binds to
93-
`sentry.logging.enable-logs` and controls Logs forwarding from the auto-configured Logback
92+
namespace instead. For example, `SentryProperties.Logging.logsEnabled` binds to
93+
`sentry.logging.logs-enabled` and controls Logs forwarding from the auto-configured Logback
9494
appender. `sentry.logging.enabled` separately controls whether that appender is installed.
9595

9696
Do not add or restore `sentry.logs.enabled` or `sentry.metrics.enabled`. Spring detects those legacy
@@ -110,12 +110,12 @@ They capture whenever their scopes are enabled, then apply signal behavior such
110110

111111
Automatic integrations must check their source-local opt-in without affecting their existing event
112112
or breadcrumb paths. Current Logs controls are:
113-
- Logback: appender `enableLogs`
114-
- Log4j2: appender `enableLogs`
115-
- JUL: handler `enableLogs`
116-
- Spring Boot Logback: `sentry.logging.enable-logs`
117-
- Timber: `enableTimberLogs` / `io.sentry.timber.logs.enabled`
118-
- Logcat: `enableLogcatLogs` / `io.sentry.logcat.logs.enabled`
113+
- Logback: appender `logsEnabled`
114+
- Log4j2: appender `logsEnabled`
115+
- JUL: handler `logsEnabled`
116+
- Spring Boot Logback: `sentry.logging.logs-enabled`
117+
- Timber: `timberLogsEnabled` / `io.sentry.timber.logs.enabled`
118+
- Logcat: `logcatLogsEnabled` / `io.sentry.logcat.logs.enabled`
119119

120120
All source-local options default to `false` and gate only Sentry Logs forwarding.
121121

sentry-android-core/api/sentry-android-core.api

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,13 @@ public final class io/sentry/android/core/SentryAndroidOptions : io/sentry/Sentr
408408
public fun getBeforeViewHierarchyCaptureCallback ()Lio/sentry/android/core/SentryAndroidOptions$BeforeCaptureCallback;
409409
public fun getDebugImagesLoader ()Lio/sentry/android/core/IDebugImagesLoader;
410410
public fun getFrameMetricsCollector ()Lio/sentry/android/core/internal/util/SentryFrameMetricsCollector;
411+
public fun getLogcatLogsEnabled ()Z
411412
public fun getNativeSdkName ()Ljava/lang/String;
412413
public fun getNdkAppHangTimeoutIntervalMillis ()J
413414
public fun getNdkHandlerStrategy ()I
414415
public fun getScreenshot ()Lio/sentry/android/core/SentryScreenshotOptions;
415416
public fun getStartupCrashDurationThresholdMillis ()J
417+
public fun getTimberLogsEnabled ()Z
416418
public fun isAnrEnabled ()Z
417419
public fun isAnrProfilingEnabled ()Z
418420
public fun isAnrReportInDebug ()Z
@@ -430,7 +432,6 @@ public final class io/sentry/android/core/SentryAndroidOptions : io/sentry/Sentr
430432
public fun isEnableAutoActivityLifecycleTracing ()Z
431433
public fun isEnableAutoTraceIdGeneration ()Z
432434
public fun isEnableFramesTracking ()Z
433-
public fun isEnableLogcatLogs ()Z
434435
public fun isEnableNdk ()Z
435436
public fun isEnableNdkAppHangTracking ()Z
436437
public fun isEnableNetworkEventBreadcrumbs ()Z
@@ -440,7 +441,6 @@ public final class io/sentry/android/core/SentryAndroidOptions : io/sentry/Sentr
440441
public fun isEnableStandaloneAppStartTracing ()Z
441442
public fun isEnableSystemEventBreadcrumbs ()Z
442443
public fun isEnableSystemEventBreadcrumbsExtras ()Z
443-
public fun isEnableTimberLogs ()Z
444444
public fun isReportHistoricalAnrs ()Z
445445
public fun isReportHistoricalTombstones ()Z
446446
public fun isTombstoneEnabled ()Z
@@ -465,7 +465,6 @@ public final class io/sentry/android/core/SentryAndroidOptions : io/sentry/Sentr
465465
public fun setEnableAutoActivityLifecycleTracing (Z)V
466466
public fun setEnableAutoTraceIdGeneration (Z)V
467467
public fun setEnableFramesTracking (Z)V
468-
public fun setEnableLogcatLogs (Z)V
469468
public fun setEnableNdk (Z)V
470469
public fun setEnableNdkAppHangTracking (Z)V
471470
public fun setEnableNetworkEventBreadcrumbs (Z)V
@@ -475,13 +474,14 @@ public final class io/sentry/android/core/SentryAndroidOptions : io/sentry/Sentr
475474
public fun setEnableStandaloneAppStartTracing (Z)V
476475
public fun setEnableSystemEventBreadcrumbs (Z)V
477476
public fun setEnableSystemEventBreadcrumbsExtras (Z)V
478-
public fun setEnableTimberLogs (Z)V
479477
public fun setFrameMetricsCollector (Lio/sentry/android/core/internal/util/SentryFrameMetricsCollector;)V
478+
public fun setLogcatLogsEnabled (Z)V
480479
public fun setNativeHandlerStrategy (Lio/sentry/android/core/NdkHandlerStrategy;)V
481480
public fun setNativeSdkName (Ljava/lang/String;)V
482481
public fun setNdkAppHangTimeoutIntervalMillis (J)V
483482
public fun setReportHistoricalAnrs (Z)V
484483
public fun setReportHistoricalTombstones (Z)V
484+
public fun setTimberLogsEnabled (Z)V
485485
public fun setTombstoneEnabled (Z)V
486486
}
487487

sentry-android-core/src/main/java/io/sentry/android/core/AndroidOptionsInitializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ static void installDefaultIntegrations(
473473
}
474474

475475
if (isTimberAvailable) {
476-
options.addIntegration(new SentryTimberIntegration(options::isEnableTimberLogs));
476+
options.addIntegration(new SentryTimberIntegration(options::getTimberLogsEnabled));
477477
}
478478
options.addIntegration(new AppComponentsBreadcrumbsIntegration(context));
479479
options.addIntegration(new SystemEventsBreadcrumbsIntegration(context));

sentry-android-core/src/main/java/io/sentry/android/core/ManifestMetadataReader.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -746,11 +746,11 @@ static void applyMetadata(
746746
}
747747
}
748748

749-
options.setEnableTimberLogs(
750-
readBool(metadata, logger, ENABLE_TIMBER_LOGS, options.isEnableTimberLogs()));
749+
options.setTimberLogsEnabled(
750+
readBool(metadata, logger, ENABLE_TIMBER_LOGS, options.getTimberLogsEnabled()));
751751

752-
options.setEnableLogcatLogs(
753-
readBool(metadata, logger, ENABLE_LOGCAT_LOGS, options.isEnableLogcatLogs()));
752+
options.setLogcatLogsEnabled(
753+
readBool(metadata, logger, ENABLE_LOGCAT_LOGS, options.getLogcatLogsEnabled()));
754754

755755
final @NotNull SentryFeedbackOptions feedbackOptions = options.getFeedbackOptions();
756756
feedbackOptions.setNameRequired(

sentry-android-core/src/main/java/io/sentry/android/core/SentryAndroidOptions.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ public final class SentryAndroidOptions extends SentryOptions {
7272
private boolean enableNetworkEventBreadcrumbs = true;
7373

7474
/** Enable or disable automatic Sentry Logs capture from Timber. Default is disabled. */
75-
private boolean enableTimberLogs = false;
75+
private boolean timberLogsEnabled = false;
7676

7777
/** Enable or disable automatic Sentry Logs capture from Logcat. Default is disabled. */
78-
private boolean enableLogcatLogs = false;
78+
private boolean logcatLogsEnabled = false;
7979

8080
/**
8181
* Enables the Auto instrumentation for Activity lifecycle tracing.
@@ -463,20 +463,20 @@ public void setEnableNetworkEventBreadcrumbs(boolean enableNetworkEventBreadcrum
463463
this.enableNetworkEventBreadcrumbs = enableNetworkEventBreadcrumbs;
464464
}
465465

466-
public boolean isEnableTimberLogs() {
467-
return enableTimberLogs;
466+
public boolean getTimberLogsEnabled() {
467+
return timberLogsEnabled;
468468
}
469469

470-
public void setEnableTimberLogs(boolean enableTimberLogs) {
471-
this.enableTimberLogs = enableTimberLogs;
470+
public void setTimberLogsEnabled(boolean timberLogsEnabled) {
471+
this.timberLogsEnabled = timberLogsEnabled;
472472
}
473473

474-
public boolean isEnableLogcatLogs() {
475-
return enableLogcatLogs;
474+
public boolean getLogcatLogsEnabled() {
475+
return logcatLogsEnabled;
476476
}
477477

478-
public void setEnableLogcatLogs(boolean enableLogcatLogs) {
479-
this.enableLogcatLogs = enableLogcatLogs;
478+
public void setLogcatLogsEnabled(boolean logcatLogsEnabled) {
479+
this.logcatLogsEnabled = logcatLogsEnabled;
480480
}
481481

482482
/**

sentry-android-core/src/main/java/io/sentry/android/core/SentryLogcatAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private static void addAsLog(
5555
final @NotNull ScopesAdapter scopes = ScopesAdapter.getInstance();
5656
final @NotNull SentryOptions options = scopes.getOptions();
5757
if (!(options instanceof SentryAndroidOptions)
58-
|| !((SentryAndroidOptions) options).isEnableLogcatLogs()) {
58+
|| !((SentryAndroidOptions) options).getLogcatLogsEnabled()) {
5959
return;
6060
}
6161
final @Nullable String trMessage = tr != null ? tr.getMessage() : null;

sentry-android-core/src/test/java/io/sentry/android/core/AndroidOptionsInitializerTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -704,18 +704,18 @@ class AndroidOptionsInitializerTest {
704704
val actual =
705705
fixture.sentryOptions.integrations.firstOrNull { it is SentryTimberIntegration }
706706
as SentryTimberIntegration
707-
assertFalse(actual.enableLogs)
707+
assertFalse(actual.logsEnabled)
708708
}
709709

710710
@Test
711711
fun `SentryTimberIntegration receives Timber logs option`() {
712-
fixture.sentryOptions.isEnableTimberLogs = true
712+
fixture.sentryOptions.timberLogsEnabled = true
713713
fixture.initSutWithClassLoader(isTimberAvailable = true)
714714

715715
val actual =
716716
fixture.sentryOptions.integrations.firstOrNull { it is SentryTimberIntegration }
717717
as SentryTimberIntegration
718-
assertTrue(actual.enableLogs)
718+
assertTrue(actual.logsEnabled)
719719
}
720720

721721
@Test

sentry-android-core/src/test/java/io/sentry/android/core/ManifestMetadataReaderTest.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,14 +1975,14 @@ class ManifestMetadataReaderTest {
19751975
"integrations now require their own opt-ins.",
19761976
*emptyArray(),
19771977
)
1978-
assertThat(fixture.options.isEnableTimberLogs).isFalse()
1979-
assertThat(fixture.options.isEnableLogcatLogs).isFalse()
1978+
assertThat(fixture.options.timberLogsEnabled).isFalse()
1979+
assertThat(fixture.options.logcatLogsEnabled).isFalse()
19801980
}
19811981

19821982
@Test
19831983
fun `applyMetadata warns when legacy logs enabled metadata is false`() {
1984-
fixture.options.isEnableTimberLogs = true
1985-
fixture.options.isEnableLogcatLogs = true
1984+
fixture.options.timberLogsEnabled = true
1985+
fixture.options.logcatLogsEnabled = true
19861986
val bundle = bundleOf(ManifestMetadataReader.ENABLE_LOGS to false)
19871987
val context = fixture.getContext(metaData = bundle)
19881988

@@ -1996,8 +1996,8 @@ class ManifestMetadataReaderTest {
19961996
"enabled through their own opt-ins.",
19971997
*emptyArray(),
19981998
)
1999-
assertThat(fixture.options.isEnableTimberLogs).isTrue()
2000-
assertThat(fixture.options.isEnableLogcatLogs).isTrue()
1999+
assertThat(fixture.options.timberLogsEnabled).isTrue()
2000+
assertThat(fixture.options.logcatLogsEnabled).isTrue()
20012001
}
20022002

20032003
@Test
@@ -2006,7 +2006,7 @@ class ManifestMetadataReaderTest {
20062006

20072007
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
20082008

2009-
assertFalse(fixture.options.isEnableTimberLogs)
2009+
assertFalse(fixture.options.timberLogsEnabled)
20102010
}
20112011

20122012
@Test
@@ -2016,7 +2016,7 @@ class ManifestMetadataReaderTest {
20162016

20172017
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
20182018

2019-
assertTrue(fixture.options.isEnableTimberLogs)
2019+
assertTrue(fixture.options.timberLogsEnabled)
20202020
}
20212021

20222022
@Test
@@ -2025,7 +2025,7 @@ class ManifestMetadataReaderTest {
20252025

20262026
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
20272027

2028-
assertThat(fixture.options.isEnableLogcatLogs).isFalse()
2028+
assertThat(fixture.options.logcatLogsEnabled).isFalse()
20292029
}
20302030

20312031
@Test
@@ -2035,18 +2035,18 @@ class ManifestMetadataReaderTest {
20352035

20362036
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
20372037

2038-
assertThat(fixture.options.isEnableLogcatLogs).isTrue()
2038+
assertThat(fixture.options.logcatLogsEnabled).isTrue()
20392039
}
20402040

20412041
@Test
20422042
fun `applyMetadata reads Logcat logs disabled to options`() {
2043-
fixture.options.isEnableLogcatLogs = true
2043+
fixture.options.logcatLogsEnabled = true
20442044
val bundle = bundleOf(ManifestMetadataReader.ENABLE_LOGCAT_LOGS to false)
20452045
val context = fixture.getContext(metaData = bundle)
20462046

20472047
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
20482048

2049-
assertThat(fixture.options.isEnableLogcatLogs).isFalse()
2049+
assertThat(fixture.options.logcatLogsEnabled).isFalse()
20502050
}
20512051

20522052
@Test

sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidOptionsTest.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,28 +98,28 @@ class SentryAndroidOptionsTest {
9898
fun `Timber logs are disabled by default`() {
9999
val sentryOptions = SentryAndroidOptions()
100100

101-
assertFalse(sentryOptions.isEnableTimberLogs)
101+
assertFalse(sentryOptions.timberLogsEnabled)
102102
}
103103

104104
@Test
105105
fun `Timber logs can be enabled`() {
106106
val sentryOptions = SentryAndroidOptions()
107-
sentryOptions.isEnableTimberLogs = true
107+
sentryOptions.timberLogsEnabled = true
108108

109-
assertTrue(sentryOptions.isEnableTimberLogs)
109+
assertTrue(sentryOptions.timberLogsEnabled)
110110
}
111111

112112
@Test
113113
fun `Logcat logs are disabled by default`() {
114-
assertThat(SentryAndroidOptions().isEnableLogcatLogs).isFalse()
114+
assertThat(SentryAndroidOptions().logcatLogsEnabled).isFalse()
115115
}
116116

117117
@Test
118118
fun `Logcat logs can be enabled`() {
119119
val sentryOptions = SentryAndroidOptions()
120-
sentryOptions.isEnableLogcatLogs = true
120+
sentryOptions.logcatLogsEnabled = true
121121

122-
assertThat(sentryOptions.isEnableLogcatLogs).isTrue()
122+
assertThat(sentryOptions.logcatLogsEnabled).isTrue()
123123
}
124124

125125
@Test

sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ class SentryAndroidTest {
244244
fun `auto-installed Timber integration uses Logs option set in configuration callback`() {
245245
val logs = mutableListOf<SentryLogEvent>()
246246
fixture.initSut { options ->
247-
options.isEnableTimberLogs = true
247+
options.timberLogsEnabled = true
248248
options.logs.beforeSend =
249249
SentryOptions.Logs.BeforeSendLogCallback { log ->
250250
logs.add(log)
@@ -268,7 +268,7 @@ class SentryAndroidTest {
268268
val logs = mutableListOf<SentryLogEvent>()
269269

270270
initForTest(mockContext) { options ->
271-
options.isEnableTimberLogs = false
271+
options.timberLogsEnabled = false
272272
options.logs.beforeSend =
273273
SentryOptions.Logs.BeforeSendLogCallback { log ->
274274
logs.add(log)

0 commit comments

Comments
 (0)