Commit 05e71d11 authored by Lucio Maciel's avatar Lucio Maciel

HttpLoggingInterceptor to log to Timber

parent cadc0ed5
...@@ -38,6 +38,7 @@ import kotlinx.coroutines.experimental.Job ...@@ -38,6 +38,7 @@ import kotlinx.coroutines.experimental.Job
import okhttp3.Interceptor import okhttp3.Interceptor
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor import okhttp3.logging.HttpLoggingInterceptor
import timber.log.Timber
import javax.inject.Singleton import javax.inject.Singleton
@Module @Module
...@@ -82,11 +83,14 @@ class AppModule { ...@@ -82,11 +83,14 @@ class AppModule {
@Provides @Provides
@Singleton @Singleton
fun provideHttpLoggingInterceptor(): HttpLoggingInterceptor { fun provideHttpLoggingInterceptor(): HttpLoggingInterceptor {
val interceptor = HttpLoggingInterceptor() val interceptor = HttpLoggingInterceptor(HttpLoggingInterceptor.Logger { message ->
Timber.d(message)
})
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
interceptor.level = HttpLoggingInterceptor.Level.BODY interceptor.level = HttpLoggingInterceptor.Level.BODY
} else { } else {
interceptor.level = HttpLoggingInterceptor.Level.HEADERS // TODO - change to HEADERS on production...
interceptor.level = HttpLoggingInterceptor.Level.BODY
} }
return interceptor return interceptor
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment