JakeWharton / timber

A logger with a small, extensible API which provides utility on top of Android's normal Log class.
https://jakewharton.github.io/timber/docs/5.x/
Apache License 2.0
10.46k stars 961 forks source link

Timber.d with %chinese throw UnknownFormatConversionException #497

Closed muedsa closed 7 months ago

muedsa commented 7 months ago

I have a proxy class

class LogUtil {
    companion object {
        @JvmStatic
        fun d(message: String?, vararg args: Any?) {
            Timber.d(message, args)
        }
    }
}

example: LogUtil.d("Click %爱") If args is empty array, get Fatal Exception: java.util.UnknownFormatConversionException Conversion = '爱' and app crash

JakeWharton commented 7 months ago

This is expected, for better or worse. You have to use %% to escape the format specifier. The output always flows into String.format, even when there are no args.