Skip to content

Commit 9bb89b8

Browse files
adinauerclaude
andcommitted
ref(android): Clarify automatic log capture option names
Rename the Timber and Logcat options to make it explicit that they control capture into Sentry rather than output to those logging systems. Keep natural property syntax for Kotlin callers and align tests and guidance with the new names. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7ce04f5 commit 9bb89b8

11 files changed

Lines changed: 59 additions & 58 deletions

‎.cursor/rules/options.mdc‎

Lines changed: 3 additions & 3 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.setLogcatLogsEnabled(...)` for `io.sentry.logcat.logs.enabled`
79+
`options.setLogcatLogCaptureEnabled(...)` 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.
8282

@@ -114,8 +114,8 @@ or breadcrumb paths. Current Logs controls are:
114114
- Log4j2: appender `logsEnabled`
115115
- JUL: handler `logsEnabled`
116116
- Spring Boot Logback: `sentry.logging.logs-enabled`
117-
- Timber: `timberLogsEnabled` / `io.sentry.timber.logs.enabled`
118-
- Logcat: `logcatLogsEnabled` / `io.sentry.logcat.logs.enabled`
117+
- Timber: `timberLogCaptureEnabled` / `io.sentry.timber.logs.enabled`
118+
- Logcat: `logcatLogCaptureEnabled` / `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
@@ -429,14 +429,14 @@ public final class io/sentry/android/core/SentryAndroidOptions : io/sentry/Sentr
429429
public fun getBeforeViewHierarchyCaptureCallback ()Lio/sentry/android/core/SentryAndroidOptions$BeforeCaptureCallback;
430430
public fun getDebugImagesLoader ()Lio/sentry/android/core/IDebugImagesLoader;
431431
public fun getFrameMetricsCollector ()Lio/sentry/android/core/internal/util/SentryFrameMetricsCollector;
432-
public fun getLogcatLogsEnabled ()Z
432+
public fun getLogcatLogCaptureEnabled ()Z
433433
public fun getMonotonicTicker ()Lio/sentry/time/MonotonicTicker;
434434
public fun getNativeSdkName ()Ljava/lang/String;
435435
public fun getNdkAppHangTimeoutIntervalMillis ()J
436436
public fun getNdkHandlerStrategy ()I
437437
public fun getScreenshot ()Lio/sentry/android/core/SentryScreenshotOptions;
438438
public fun getStartupCrashDurationThresholdMillis ()J
439-
public fun getTimberLogsEnabled ()Z
439+
public fun getTimberLogCaptureEnabled ()Z
440440
public fun getTombstoneMergeTimeThresholdMillis ()J
441441
public fun isAnrEnabled ()Z
442442
public fun isAnrProfilingEnabled ()Z
@@ -500,15 +500,15 @@ public final class io/sentry/android/core/SentryAndroidOptions : io/sentry/Sentr
500500
public fun setEnableSystemEventBreadcrumbs (Z)V
501501
public fun setEnableSystemEventBreadcrumbsExtras (Z)V
502502
public fun setFrameMetricsCollector (Lio/sentry/android/core/internal/util/SentryFrameMetricsCollector;)V
503-
public fun setLogcatLogsEnabled (Z)V
503+
public fun setLogcatLogCaptureEnabled (Z)V
504504
public fun setMemoryLimiterEnabled (Z)V
505505
public fun setNativeHandlerStrategy (Lio/sentry/android/core/NdkHandlerStrategy;)V
506506
public fun setNativeSdkName (Ljava/lang/String;)V
507507
public fun setNdkAppHangTimeoutIntervalMillis (J)V
508508
public fun setReportHistoricalAnrs (Z)V
509509
public fun setReportHistoricalMemoryLimiterExits (Z)V
510510
public fun setReportHistoricalTombstones (Z)V
511-
public fun setTimberLogsEnabled (Z)V
511+
public fun setTimberLogCaptureEnabled (Z)V
512512
public fun setTombstoneEnabled (Z)V
513513
public fun setTombstoneMergeTimeThresholdMillis (J)V
514514
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,8 @@ static void installDefaultIntegrations(
479479
}
480480

481481
if (isTimberAvailable) {
482-
options.addIntegration(new SentryTimberIntegration(options::getTimberLogsEnabled));
482+
options.addIntegration(
483+
new SentryTimberIntegration(() -> options.getTimberLogCaptureEnabled()));
483484
}
484485
options.addIntegration(new AppComponentsBreadcrumbsIntegration(context));
485486
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
@@ -750,11 +750,11 @@ static void applyMetadata(
750750
}
751751
}
752752

753-
options.setTimberLogsEnabled(
754-
readBool(metadata, logger, ENABLE_TIMBER_LOGS, options.getTimberLogsEnabled()));
753+
options.setTimberLogCaptureEnabled(
754+
readBool(metadata, logger, ENABLE_TIMBER_LOGS, options.getTimberLogCaptureEnabled()));
755755

756-
options.setLogcatLogsEnabled(
757-
readBool(metadata, logger, ENABLE_LOGCAT_LOGS, options.getLogcatLogsEnabled()));
756+
options.setLogcatLogCaptureEnabled(
757+
readBool(metadata, logger, ENABLE_LOGCAT_LOGS, options.getLogcatLogCaptureEnabled()));
758758

759759
final @NotNull SentryFeedbackOptions feedbackOptions = options.getFeedbackOptions();
760760
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
@@ -76,10 +76,10 @@ public final class SentryAndroidOptions extends SentryOptions {
7676
private boolean enableNetworkEventBreadcrumbs = true;
7777

7878
/** Enable or disable automatic Sentry Logs capture from Timber. Default is disabled. */
79-
private boolean timberLogsEnabled = false;
79+
private boolean timberLogCaptureEnabled = false;
8080

8181
/** Enable or disable automatic Sentry Logs capture from Logcat. Default is disabled. */
82-
private boolean logcatLogsEnabled = false;
82+
private boolean logcatLogCaptureEnabled = false;
8383

8484
/**
8585
* Enables the Auto instrumentation for Activity lifecycle tracing.
@@ -511,20 +511,20 @@ public void setEnableNetworkEventBreadcrumbs(boolean enableNetworkEventBreadcrum
511511
this.enableNetworkEventBreadcrumbs = enableNetworkEventBreadcrumbs;
512512
}
513513

514-
public boolean getTimberLogsEnabled() {
515-
return timberLogsEnabled;
514+
public boolean getTimberLogCaptureEnabled() {
515+
return timberLogCaptureEnabled;
516516
}
517517

518-
public void setTimberLogsEnabled(boolean timberLogsEnabled) {
519-
this.timberLogsEnabled = timberLogsEnabled;
518+
public void setTimberLogCaptureEnabled(boolean timberLogCaptureEnabled) {
519+
this.timberLogCaptureEnabled = timberLogCaptureEnabled;
520520
}
521521

522-
public boolean getLogcatLogsEnabled() {
523-
return logcatLogsEnabled;
522+
public boolean getLogcatLogCaptureEnabled() {
523+
return logcatLogCaptureEnabled;
524524
}
525525

526-
public void setLogcatLogsEnabled(boolean logcatLogsEnabled) {
527-
this.logcatLogsEnabled = logcatLogsEnabled;
526+
public void setLogcatLogCaptureEnabled(boolean logcatLogCaptureEnabled) {
527+
this.logcatLogCaptureEnabled = logcatLogCaptureEnabled;
528528
}
529529

530530
/**

‎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).getLogcatLogsEnabled()) {
58+
|| !((SentryAndroidOptions) options).getLogcatLogCaptureEnabled()) {
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,8 +713,8 @@ class AndroidOptionsInitializerTest {
713713
}
714714

715715
@Test
716-
fun `SentryTimberIntegration receives Timber logs option`() {
717-
fixture.sentryOptions.timberLogsEnabled = true
716+
fun `SentryTimberIntegration receives Timber log capture option`() {
717+
fixture.sentryOptions.timberLogCaptureEnabled = true
718718
fixture.initSutWithClassLoader(isTimberAvailable = true)
719719

720720
val actual =

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2176,52 +2176,52 @@ class ManifestMetadataReaderTest {
21762176
}
21772177

21782178
@Test
2179-
fun `applyMetadata keeps Timber logs disabled if not found`() {
2179+
fun `applyMetadata keeps Timber log capture disabled if not found`() {
21802180
val context = fixture.getContext()
21812181

21822182
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
21832183

2184-
assertFalse(fixture.options.timberLogsEnabled)
2184+
assertFalse(fixture.options.timberLogCaptureEnabled)
21852185
}
21862186

21872187
@Test
2188-
fun `applyMetadata reads Timber logs enabled to options`() {
2188+
fun `applyMetadata reads Timber log capture enabled to options`() {
21892189
val bundle = bundleOf(ManifestMetadataReader.ENABLE_TIMBER_LOGS to true)
21902190
val context = fixture.getContext(metaData = bundle)
21912191

21922192
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
21932193

2194-
assertTrue(fixture.options.timberLogsEnabled)
2194+
assertTrue(fixture.options.timberLogCaptureEnabled)
21952195
}
21962196

21972197
@Test
2198-
fun `applyMetadata keeps Logcat logs disabled if not found`() {
2198+
fun `applyMetadata keeps Logcat log capture disabled if not found`() {
21992199
val context = fixture.getContext()
22002200

22012201
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
22022202

2203-
assertThat(fixture.options.logcatLogsEnabled).isFalse()
2203+
assertThat(fixture.options.logcatLogCaptureEnabled).isFalse()
22042204
}
22052205

22062206
@Test
2207-
fun `applyMetadata reads Logcat logs enabled to options`() {
2207+
fun `applyMetadata reads Logcat log capture enabled to options`() {
22082208
val bundle = bundleOf(ManifestMetadataReader.ENABLE_LOGCAT_LOGS to true)
22092209
val context = fixture.getContext(metaData = bundle)
22102210

22112211
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
22122212

2213-
assertThat(fixture.options.logcatLogsEnabled).isTrue()
2213+
assertThat(fixture.options.logcatLogCaptureEnabled).isTrue()
22142214
}
22152215

22162216
@Test
2217-
fun `applyMetadata reads Logcat logs disabled to options`() {
2218-
fixture.options.logcatLogsEnabled = true
2217+
fun `applyMetadata reads Logcat log capture disabled to options`() {
2218+
fixture.options.logcatLogCaptureEnabled = true
22192219
val bundle = bundleOf(ManifestMetadataReader.ENABLE_LOGCAT_LOGS to false)
22202220
val context = fixture.getContext(metaData = bundle)
22212221

22222222
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
22232223

2224-
assertThat(fixture.options.logcatLogsEnabled).isFalse()
2224+
assertThat(fixture.options.logcatLogCaptureEnabled).isFalse()
22252225
}
22262226

22272227
@Test

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,31 +95,31 @@ class SentryAndroidOptionsTest {
9595
}
9696

9797
@Test
98-
fun `Timber logs are disabled by default`() {
98+
fun `Timber log capture is disabled by default`() {
9999
val sentryOptions = SentryAndroidOptions()
100100

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

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

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

112112
@Test
113-
fun `Logcat logs are disabled by default`() {
114-
assertThat(SentryAndroidOptions().logcatLogsEnabled).isFalse()
113+
fun `Logcat log capture is disabled by default`() {
114+
assertThat(SentryAndroidOptions().logcatLogCaptureEnabled).isFalse()
115115
}
116116

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

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

125125
@Test

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,10 @@ class SentryAndroidTest {
241241
}
242242

243243
@Test
244-
fun `auto-installed Timber integration uses Logs option set in configuration callback`() {
244+
fun `auto-installed Timber integration uses log capture option set in configuration callback`() {
245245
val logs = mutableListOf<SentryLogEvent>()
246246
fixture.initSut { options ->
247-
options.timberLogsEnabled = true
247+
options.timberLogCaptureEnabled = 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.timberLogsEnabled = false
271+
options.timberLogCaptureEnabled = false
272272
options.logs.beforeSend =
273273
SentryOptions.Logs.BeforeSendLogCallback { log ->
274274
logs.add(log)

0 commit comments

Comments
 (0)