-
-
Notifications
You must be signed in to change notification settings - Fork 475
fix(android): [Logs and Metrics Enable Flags 19] Read Timber option lazily #5964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: docs/update-options-guidance
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import io.sentry.SentryLogLevel | |
| import io.sentry.SentryOptions | ||
| import io.sentry.android.timber.BuildConfig.VERSION_NAME | ||
| import io.sentry.util.IntegrationUtils.addIntegrationToSdkVersion | ||
| import io.sentry.util.LazyEvaluator.Evaluator | ||
| import java.io.Closeable | ||
| import timber.log.Timber | ||
|
|
||
|
|
@@ -18,11 +19,13 @@ public class SentryTimberIntegration( | |
| public val minBreadcrumbLevel: SentryLevel = SentryLevel.INFO, | ||
| public val minLogsLevel: SentryLogLevel = SentryLogLevel.INFO, | ||
| ) : Integration, Closeable { | ||
| public var enableLogs: Boolean = false | ||
| private set | ||
| public val enableLogs: Boolean | ||
| get() = enableLogsProvider.evaluate() | ||
|
|
||
| private var enableLogsProvider: Evaluator<Boolean> = Evaluator { false } | ||
|
|
||
| public constructor(enableLogs: Boolean) : this() { | ||
| this.enableLogs = enableLogs | ||
| enableLogsProvider = Evaluator { enableLogs } | ||
| } | ||
|
|
||
| public constructor( | ||
|
|
@@ -31,7 +34,11 @@ public class SentryTimberIntegration( | |
| minLogsLevel: SentryLogLevel, | ||
| enableLogs: Boolean, | ||
| ) : this(minEventLevel, minBreadcrumbLevel, minLogsLevel) { | ||
| this.enableLogs = enableLogs | ||
| enableLogsProvider = Evaluator { enableLogs } | ||
| } | ||
|
|
||
| public constructor(enableLogsProvider: Evaluator<Boolean>) : this() { | ||
| this.enableLogsProvider = enableLogsProvider | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Internal type in public constructorMedium Severity The new public Reviewed by Cursor Bugbot for commit 4d120ff. Configure here. |
||
| } | ||
|
|
||
| private lateinit var tree: SentryTimberTree | ||
|
|
@@ -47,7 +54,14 @@ public class SentryTimberIntegration( | |
| override fun register(scopes: IScopes, options: SentryOptions) { | ||
| logger = options.logger | ||
|
|
||
| tree = SentryTimberTree(scopes, minEventLevel, minBreadcrumbLevel, minLogsLevel, enableLogs) | ||
| tree = | ||
| SentryTimberTree( | ||
| scopes, | ||
| minEventLevel, | ||
| minBreadcrumbLevel, | ||
| minLogsLevel, | ||
| enableLogsProvider.evaluate(), | ||
| ) | ||
| Timber.plant(tree) | ||
|
|
||
| logger.log(SentryLevel.DEBUG, "SentryTimberIntegration installed.") | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: A method reference
options::isEnableTimberLogswas introduced, violating a class-level suppression intended to prevent them due to compatibility issues with older Android Gradle Plugin versions.Severity: MEDIUM
Suggested Fix
To maintain compatibility with older Android Gradle Plugin versions, replace the method reference with an explicit lambda expression. Change
new SentryTimberIntegration(options::isEnableTimberLogs)tonew SentryTimberIntegration(() -> options.isEnableTimberLogs()), which aligns with the established pattern in the file.Prompt for AI Agent
Did we get this right? 👍 / 👎 to inform future reviews.