Timber
The sentry-android-timber
library provides Timber support for Sentry via Timber Tree that sends events and breadcrumbs to Sentry. Once this integration is configured you can use Timber’s static API.
The source can be found on GitHub.
Installation
In order to add the Timber integration, you have to do a manual initialization of the Android SDK.
Add the
sentry-android-timber
dependencyUsing Gradle:
Copiedimplementation 'io.sentry:sentry-android:3.1.0' implementation 'io.sentry:sentry-android-timber:3.1.0'
Initialize and add the
SentryTimberIntegration
CopiedSentryAndroid.init(context) { options -> if (!BuildConfig.DEBUG) { // default values: // minEventLevel = ERROR // minBreadcrumbLevel = INFO options.addIntegration(SentryTimberIntegration( minEventLevel = SentryLevel.ERROR, minBreadcrumbLevel = SentryLevel.INFO)) } }
Usage
The following example adds a breadcrumb and captures an error using the Timber’s static API; this breadcrumb and error will be forwarded to Sentry.
Copied
fun division(x: Int = 5, y: Int = 0): Int {
Timber.i("x = $x, y = $y")
try {
return x / y
} catch (e: ArithmeticException) {
Timber.e(e, "Division error")
}
return 0
}
You can edit this page on GitHub.