From 16b232d2a39f1f4b86ccb11cb611e594e3a86792 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Fri, 7 Jun 2019 02:03:17 -0700 Subject: [PATCH] Enable okhttp logging in debug only --- .../com/topjohnwu/magisk/di/NetworkingModule.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/di/NetworkingModule.kt b/app/src/main/java/com/topjohnwu/magisk/di/NetworkingModule.kt index 030a0034c..00aea7265 100644 --- a/app/src/main/java/com/topjohnwu/magisk/di/NetworkingModule.kt +++ b/app/src/main/java/com/topjohnwu/magisk/di/NetworkingModule.kt @@ -2,6 +2,7 @@ package com.topjohnwu.magisk.di import com.squareup.moshi.JsonAdapter import com.squareup.moshi.Moshi +import com.topjohnwu.magisk.BuildConfig import com.topjohnwu.magisk.Constants import com.topjohnwu.magisk.data.network.GithubRawApiServices import okhttp3.OkHttpClient @@ -23,13 +24,16 @@ val networkingModule = module { } fun createOkHttpClient(): OkHttpClient { - val httpLoggingInterceptor = HttpLoggingInterceptor().apply { - level = HttpLoggingInterceptor.Level.BODY + val builder = OkHttpClient.Builder() + + if (BuildConfig.DEBUG) { + val httpLoggingInterceptor = HttpLoggingInterceptor().apply { + level = HttpLoggingInterceptor.Level.BODY + } + builder.addInterceptor(httpLoggingInterceptor) } - return OkHttpClient.Builder() - .addInterceptor(httpLoggingInterceptor) - .build() + return builder.build() } fun createConverterFactory(): Converter.Factory {