From e68197c9bcae87e954e28eac487e480e020894cf Mon Sep 17 00:00:00 2001 From: DOGDDUDDY Date: Sat, 16 Sep 2023 20:32:18 +0900 Subject: [PATCH] =?UTF-8?q?[feat/mypage=5Fregistered]:=20Stetho=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 5 +++++ app/src/main/java/org/gdsc/jmt/App.kt | 6 ++++++ data/build.gradle | 5 +++++ .../java/org/gdsc/data/di/NetworkModule.kt | 20 +++++++++++++++---- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d9e82184..eaa45425 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -68,4 +68,9 @@ dependencies { testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + + // Stetho + implementation 'com.facebook.stetho:stetho:1.6.0' + implementation 'com.facebook.stetho:stetho-okhttp3:1.6.0' + implementation 'com.facebook.stetho:stetho-js-rhino:1.6.0' } diff --git a/app/src/main/java/org/gdsc/jmt/App.kt b/app/src/main/java/org/gdsc/jmt/App.kt index 7a9b5235..fe76d813 100644 --- a/app/src/main/java/org/gdsc/jmt/App.kt +++ b/app/src/main/java/org/gdsc/jmt/App.kt @@ -1,9 +1,15 @@ package org.gdsc.jmt import android.app.Application +import com.facebook.stetho.Stetho import dagger.hilt.android.HiltAndroidApp @HiltAndroidApp class App: Application() { + override fun onCreate() { + super.onCreate() + + if (BuildConfig.DEBUG) Stetho.initializeWithDefaults(this) + } } \ No newline at end of file diff --git a/data/build.gradle b/data/build.gradle index 7822086a..36236aec 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -71,4 +71,9 @@ dependencies { implementation "androidx.room:room-ktx:2.5.0" implementation "androidx.room:room-paging:2.5.0" kapt "androidx.room:room-compiler:2.5.0" + + // Stetho + implementation 'com.facebook.stetho:stetho:1.6.0' + implementation 'com.facebook.stetho:stetho-okhttp3:1.6.0' + implementation 'com.facebook.stetho:stetho-js-rhino:1.6.0' } \ No newline at end of file diff --git a/data/src/main/java/org/gdsc/data/di/NetworkModule.kt b/data/src/main/java/org/gdsc/data/di/NetworkModule.kt index da0c560e..887ea9f1 100644 --- a/data/src/main/java/org/gdsc/data/di/NetworkModule.kt +++ b/data/src/main/java/org/gdsc/data/di/NetworkModule.kt @@ -1,6 +1,7 @@ package org.gdsc.data.di import android.content.Context +import com.facebook.stetho.okhttp3.StethoInterceptor import dagger.Module import dagger.Provides import dagger.hilt.InstallIn @@ -8,6 +9,7 @@ import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor +import org.gdsc.data.BuildConfig import org.gdsc.data.network.AuthInterceptor import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory @@ -53,11 +55,21 @@ class NetworkModule { private val baseClientBuilder: OkHttpClient.Builder get() = run { val clientBuilder = OkHttpClient.Builder() - val loggingInterceptor = HttpLoggingInterceptor().apply { - level = HttpLoggingInterceptor.Level.BODY + + clientBuilder.apply { + if (BuildConfig.DEBUG) { + addInterceptor(HttpLoggingInterceptor().apply { + level = HttpLoggingInterceptor.Level.HEADERS + }) + + addInterceptor(HttpLoggingInterceptor().apply { + level = HttpLoggingInterceptor.Level.BODY + }) + + addNetworkInterceptor(StethoInterceptor()) + } } - return clientBuilder.addInterceptor(loggingInterceptor) + return clientBuilder } - } } \ No newline at end of file