Introduction: Built upon Timber. Without performance penality.
More: Author   ReportBugs   

CI Status

Timber is a great library that makes logging very easy. However traditional logging like

if (BuildConfig.DEBUG) {
    String message = ...
    Log.d(TAG, message);

has one big advantage: The whole block will only be executed when you are in debug mode. If you pass anything to Timber, the String itself and the precalculations will be created. Even if you never planted a tree.

And this is where Slimber comes into play: It uses Kotlins inline capabilities so we can archieve the no-cost-effect because the whole block is executed only when there are trees planted. And remember: In Kotlin you can specify the last function in an arugment of a function outside the parentheses.

So you can do it like this:

d { "onCreate called with $expensiveToStringObject" }

There are also functions that take a throwable as the first paramter, so you can use them like

e(throwable) { "there was a severe error" }

Besides from that just use Timber for planting trees like you normally do



Add this to your root build.gradle

allprojects {
    repositories {
        maven { url "" }

And then this dependency to your project:

dependencies {
    compile 'com.github.PaulWoitaschek:Slimber:x.y.z'
About Me
GitHub: Trinea
Facebook: Dev Tools