Give `Timber` a try
# android
l
Give
Timber
a try
j
It used to be my fave logger in java projects, was thinking that there is something more kotlin friendly. Cheers
n
what makes timber not kotlin friendly?
l
@Jakub Use the version 5.0.0-SNAPSHOT, it is multiplatform and more Kotlin friendly than the version 4.x
👍 2
j
@no isn’t idiomatic
I found also the repo of the guy that thought the same 🙂
l
I don't get this...
Copy code
// Standard timber
Timber.d("%d %s", intVar + 3, stringFun())

// Kotlin extensions
Timber.d { "${intVar + 3} ${stringFun()}" }
The only difference is one accepts a
()->String
as a parameter instead of a
String
value... And why would you use string format, when you can use string interpolation without this library... I'd say the author is dishonest about comparing the two...
Copy code
// Standard timber
Timber.d("${intVar + 3} ${stringFun()}")

// Kotlin extensions
Timber.d { "${intVar + 3} ${stringFun()}" }
this is more like it Why would it matter when you're evaluating the logged message? If logging slows your application so much, you're probably logging too much in the first place
l
@Lucas Ł I see no dishonesty. The string format style is officially recommended for Timber 4.x, but it's no longer necessary with lambda evaluation as it's not called if there's no tree that accepts the tag and log level. FYI, Timber 5.0.0-SNAPSHOT has basically the same Kotlin friendly API
👍 1