ajalt / timberkt

Easy Android logging with Kotlin and Timber
Apache License 2.0
205 stars 12 forks source link

Add @JvmOverloads to support optional arguments in Java #8

Open lukaville opened 6 years ago

lukaville commented 6 years ago

For example replace:

@JvmStatic inline fun i(t: Throwable? = null, message: () -> String) = log { Timber.i(t, message()) }

with

@JvmOverloads @JvmStatic inline fun i(t: Throwable? = null, message: () -> String) = log { Timber.i(t, message()) }

Currently, we have to pass null explicitly in Java

ajalt commented 6 years ago

Interesting. This is doable, but I assumed that people would use the regular Timber methods directly in Java code. What's your use case for using the extensions outside of Kotlin?

The main disadvantage of using the extension from Java is that log tag will be incorrect, since it relies on the extensions being inlined.