From 23d556ca22c91ea3e4078704914ad421f8891703 Mon Sep 17 00:00:00 2001 From: AlexMason Date: Tue, 29 Jun 2021 20:33:52 +0100 Subject: [PATCH] fixes okhttp interceptor to log only in debug --- .../android/plugev/data/common/di/DataModule.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/shevaalex/android/plugev/data/common/di/DataModule.kt b/app/src/main/java/com/shevaalex/android/plugev/data/common/di/DataModule.kt index a5fa335..d990428 100644 --- a/app/src/main/java/com/shevaalex/android/plugev/data/common/di/DataModule.kt +++ b/app/src/main/java/com/shevaalex/android/plugev/data/common/di/DataModule.kt @@ -1,5 +1,6 @@ package com.shevaalex.android.plugev.data.common.di +import com.shevaalex.android.plugev.BuildConfig import dagger.Module import dagger.Provides import dagger.hilt.InstallIn @@ -15,12 +16,13 @@ object DataModule { @Singleton @Provides fun provideOkhttpClient(): OkHttpClient { - return OkHttpClient.Builder() - .addInterceptor( - HttpLoggingInterceptor() - .setLevel(HttpLoggingInterceptor.Level.BASIC) + val builder = OkHttpClient.Builder() + if (BuildConfig.DEBUG) { + builder.addInterceptor( + HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BASIC) ) - .build() + } + return builder.build() } }