Disable extra OkHttp logging

This commit is contained in:
Kirill Kamakin
2022-04-09 15:00:11 +05:00
parent a5ae5e91cd
commit d52c428ea5
2 changed files with 6 additions and 1 deletions

View File

@@ -24,6 +24,7 @@ android {
} }
buildConfigField "Boolean", "DEBUG_PICASSO", "false" buildConfigField "Boolean", "DEBUG_PICASSO", "false"
buildConfigField "Boolean", "LOG_NETWORK", "false"
} }
signingConfigs { signingConfigs {

View File

@@ -16,6 +16,7 @@ import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent import dagger.hilt.components.SingletonComponent
import dagger.multibindings.IntoSet import dagger.multibindings.IntoSet
import gq.kirmanak.mealient.BuildConfig
import leakcanary.LeakCanary import leakcanary.LeakCanary
import okhttp3.Interceptor import okhttp3.Interceptor
import okhttp3.logging.HttpLoggingInterceptor import okhttp3.logging.HttpLoggingInterceptor
@@ -30,7 +31,10 @@ object DebugModule {
@IntoSet @IntoSet
fun provideLoggingInterceptor(): Interceptor { fun provideLoggingInterceptor(): Interceptor {
val interceptor = HttpLoggingInterceptor { message -> Timber.tag("OkHttp").v(message) } val interceptor = HttpLoggingInterceptor { message -> Timber.tag("OkHttp").v(message) }
interceptor.level = HttpLoggingInterceptor.Level.BODY interceptor.level = when {
BuildConfig.LOG_NETWORK -> HttpLoggingInterceptor.Level.BODY
else -> HttpLoggingInterceptor.Level.BASIC
}
return interceptor return interceptor
} }