Skip to content

jdsingh/papertrail-timber

Repository files navigation

papertrail-timber CircleCI

Timber tree for Papertrail logging.

How to use

Config Papertrail with your papertrail host and port. Application class is good place for this.

Kotlin

val tree = PapertrailTree.Builder()
            .system("Android")
            .program("Papertrail")
            .logger("My-App")
            .host(BuildConfig.PAPERTRAIL_HOST)
            .port(BuildConfig.PAPERTRAIL_PORT)
            // send logs to papertrail with priority Log.INFO and above
            .priority(Log.INFO)
            .build()
            
Timber.plant(tree)

Java

final PapertrailTree tree = new PapertrailTree.Builder()
            .system("Android")
            .program("Papertrail")
            .logger("My-App")
            .host(BuildConfig.PAPERTRAIL_HOST)
            .port(BuildConfig.PAPERTRAIL_PORT)
            // send logs to papertrail with priority Log.INFO and above
            .priority(Log.INFO)
            .build()
            
Timber.plant(tree)

Once this setup is done, all Timber logs will be sent to Papertrail.

Download

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Step 2. Add the dependency

dependencies {
    implementation 'com.github.jdsingh:papertrail-timber:1.0.3'
}

Proguard

consumer-proguard-rules.pro is included in the library, so you don't need to include these proguard rules separately. These are the proguard rules used for this library.

# Papertrail
-keep class org.productivity.java.syslog4j.impl.net.tcp.ssl.SSLTCPNetSyslog
-keep class org.productivity.java.syslog4j.impl.net.tcp.ssl.SSLTCPNetSyslogWriter

-dontwarn org.productivity.java.syslog4j.impl.**
-dontwarn ch.qos.logback.core.net.*

Thanks

Thanks to @tony19 for logback-android.