Skip to content

Add Timber logs#284

Closed
pedronveloso wants to merge 2 commits intomasterfrom
pedro/feb-2026/add-timber-logs
Closed

Add Timber logs#284
pedronveloso wants to merge 2 commits intomasterfrom
pedro/feb-2026/add-timber-logs

Conversation

@pedronveloso
Copy link
Copy Markdown
Contributor

This adds much needed logs via Timber (same standard we use on internal codebases). These logs are stripped from the release version of the SDK, so there is no risk of leaking any unintended information on production.

Comment on lines +32 to +34
* If your app already uses Timber, plant your trees **before** calling any Afterpay SDK methods.
* The SDK will detect existing trees and use them. If no trees exist, the SDK will plant a
* default DebugTree for DEBUG builds only.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is an internal class, how will consumers see this instruction to know the expected calling order?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this instruction is only for consumers of the debug build of this SDK, which should only be contributors to the SDK rather than real-world apps.

Comment on lines +57 to +74
if (!BuildConfig.DEBUG || loggingDisabled || initialized) return

synchronized(this) {
if (!initialized && !loggingDisabled) {
try {
if (Timber.treeCount == 0) {
Timber.plant(Timber.DebugTree())
}
initialized = true
} catch (e: LinkageError) {
// android.util.Log not available (unit tests without mocking)
loggingDisabled = true
} catch (e: ExceptionInInitializerError) {
// Timber initialization failed
loggingDisabled = true
}
}
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any benefit to using Timber if we're rewriting all the debug checks etc. anyway? May as well just drop the dep and use android.util.Log directly.

Comment on lines +24 to +31
-assumenosideeffects class timber.log.Timber {
public *** d(...);
public *** i(...);
public *** w(...);
public *** e(...);
public *** v(...);
public *** wtf(...);
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this valid to put in library rules? I.e. is R8 smart enough to not strip these if the consuming app is using them directly? I'm not an R8 expert, but it seems like stripping AfterpayLog calls should be sufficient since Timber is only used internally inside AfterpayLog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants