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

  1. In order to add the Timber integration, you have to do a manual initialization of the Android SDK.

  2. Add the sentry-android-timber dependency

    Using Gradle:

    Copied
    implementation 'io.sentry:sentry-android:{version}'
    implementation 'io.sentry:sentry-android-timber:{version}' // version >= 2.2.0
  3. Initialize and add the SentryTimberIntegration

    Copied
    SentryAndroid.init(context) { options ->
        if (!BuildConfig.DEBUG) {
    
            // default values:
            // minEventLevel = ERROR
            // minBreadcrumbLevel = INFO
            options.addIntegration(SentryTimberIntegration(
                minEventLevel = SentryLevel.ERROR,
                minBreadcrumbLevel = SentryLevel.INFO))
        }
    }
Copied

### 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.

```kotlin
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.
On this page