https://kotlinlang.org logo
#android
Title
# android
l

Lucas Ł

08/18/2018, 5:36 PM
Give
Timber
a try
j

Jakub

08/18/2018, 5:49 PM
It used to be my fave logger in java projects, was thinking that there is something more kotlin friendly. Cheers
n

no

08/18/2018, 6:19 PM
what makes timber not kotlin friendly?
l

louiscad

08/18/2018, 8:29 PM
@Jakub Use the version 5.0.0-SNAPSHOT, it is multiplatform and more Kotlin friendly than the version 4.x
👍 2
j

Jakub

08/18/2018, 8:32 PM
@no isn’t idiomatic
I found also the repo of the guy that thought the same 🙂
l

Lucas Ł

08/19/2018, 11:29 AM
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

louiscad

08/19/2018, 11:40 AM
@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
3 Views