timberkt icon indicating copy to clipboard operation
timberkt copied to clipboard

Add @JvmOverloads to support optional arguments in Java

Open lukaville opened this issue 6 years ago • 1 comments

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

lukaville avatar Jul 19 '18 13:07 lukaville

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.

ajalt avatar Jul 19 '18 15:07 ajalt