Closed gabrielle88 closed 3 years ago
You are facing the issue while formatting your log with Timber. Check Timber.d() method with args.
Yeah I don't think there's anything specific to Timber here. We just end up calling String.format
with your format string and vararg array. You'd see the same thing if you called String.format
yourself.
If you don't think this is true can you please provide an executable test case or sample app which demonstrates the problem and I'll reopen?
Hi!! I am using Timber on my app, and I use my own HttpLoggingInterceptor to get the logs from OkHttp library that I use it. I make a request to server and the url contains a serial Number that looks like this "18:93:D7:56:B1:7B". When the library try to log the url I get this error :
java.util.IllegalFormatConversionException: a != [Ljava.lang.Object; at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4402) at java.util.Formatter$FormatSpecifier.printFloat(Formatter.java:2897) at java.util.Formatter$FormatSpecifier.print(Formatter.java:2844) at java.util.Formatter.format(Formatter.java:2523) at java.util.Formatter.format(Formatter.java:2458) at java.lang.String.format(String.java:2770) at timber.log.Timber$Tree.formatMessage(Timber.java:539) at timber.log.Timber$Tree.prepareLog(Timber.java:525) at timber.log.Timber$Tree.d(Timber.java:405) at timber.log.Timber$1.d(Timber.java:243) at timber.log.Timber.d(Timber.java:38) at com.myapp.AndroidLogger.d(AndroidLogger.kt:51) at com.myapp.LoggingInterceptor.log(LoggingInterceptor.kt:7) at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:169) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:221) at okhttp3.RealCall.execute(RealCall.java:81)
How can it be fixed? I think the problem is with ":", it see the serialNumber as a HEXADECIMAL_FLOAT and when it try to print, the conversion fails.