I am trying to write all requests (with a network interceptor) using refrofit2, kotlin and logging-interceptor:
- retrofit: "2.0.2"
- okhttp3: "3.2.0"
- com.squareup.okhttp3: logging-interceptor 3.2.0
as:
val interceptor = HttpLoggingInterceptor()
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
val okHttpClient = OkHttpClient.Builder()
.addNetworkInterceptor(interceptor) // same for .addInterceptor(...)
.connectTimeout(30, TimeUnit.SECONDS) //Backend is really slow
.writeTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.build()
sRestAdapter = Retrofit.Builder()
.client(okHttpClient)
.baseUrl(if (host.endsWith("/")) host else "$host/")
.addConverterFactory(GsonConverterFactory.create(gson()))
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build()
It just prints:
D/OkHttp: --> GET url...
D/OkHttp: --> END GET
What's happening?
--------------- EDIT --------
Errors executed in the main thread are not displayed by the logger, so be careful.
source
share