From 5e8660083237103c1fb994f4b2dffece9040377c Mon Sep 17 00:00:00 2001 From: Prashan Dharmasena Date: Wed, 13 Mar 2024 11:03:06 -0400 Subject: [PATCH 1/2] Initial setup of StrictMode - only logging in debug. --- .../exchange/dydx/trading/DydxApplication.kt | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/v4/app/src/main/java/exchange/dydx/trading/DydxApplication.kt b/v4/app/src/main/java/exchange/dydx/trading/DydxApplication.kt index edcc8aff..5fd39ab7 100644 --- a/v4/app/src/main/java/exchange/dydx/trading/DydxApplication.kt +++ b/v4/app/src/main/java/exchange/dydx/trading/DydxApplication.kt @@ -1,26 +1,36 @@ package exchange.dydx.trading import android.app.Application +import android.os.StrictMode import com.facebook.stetho.Stetho import dagger.hilt.android.HiltAndroidApp import exchange.dydx.abacus.jvm.AbacusAndroid -import exchange.dydx.platformui.designSystem.theme.ThemeSettings import exchange.dydx.trading.common.AppConfig import exchange.dydx.trading.common.logger.DydxLogger import timber.log.Timber -import javax.inject.Inject @HiltAndroidApp class DydxApplication : Application() { - @Inject lateinit var logger: DydxLogger - - @Inject lateinit var themeSettings: ThemeSettings + private val logger = DydxLogger() override fun onCreate() { super.onCreate() if (BuildConfig.DEBUG) { + StrictMode.setThreadPolicy( + StrictMode.ThreadPolicy.Builder() + .detectAll() + .penaltyLog() + .build(), + ) + StrictMode.setVmPolicy( + StrictMode.VmPolicy.Builder() + .detectAll() + .penaltyLog() + .build(), + ) + Timber.plant( logger.debugTree, logger.woodTree(this), From be0845e6460f528b03be6b72b3a0871121fbed9c Mon Sep 17 00:00:00 2001 From: Prashan Dharmasena Date: Wed, 13 Mar 2024 14:42:06 -0400 Subject: [PATCH 2/2] Revert injection changes --- .../main/java/exchange/dydx/trading/DydxApplication.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/v4/app/src/main/java/exchange/dydx/trading/DydxApplication.kt b/v4/app/src/main/java/exchange/dydx/trading/DydxApplication.kt index 5fd39ab7..177e6bbb 100644 --- a/v4/app/src/main/java/exchange/dydx/trading/DydxApplication.kt +++ b/v4/app/src/main/java/exchange/dydx/trading/DydxApplication.kt @@ -5,14 +5,20 @@ import android.os.StrictMode import com.facebook.stetho.Stetho import dagger.hilt.android.HiltAndroidApp import exchange.dydx.abacus.jvm.AbacusAndroid +import exchange.dydx.platformui.designSystem.theme.ThemeSettings import exchange.dydx.trading.common.AppConfig import exchange.dydx.trading.common.logger.DydxLogger import timber.log.Timber +import javax.inject.Inject @HiltAndroidApp class DydxApplication : Application() { - private val logger = DydxLogger() + // Do not remove - this is used to trigger initialization via Dagger + // This is an anti-pattern, do not copy. + @Inject lateinit var themeSettings: ThemeSettings + + @Inject lateinit var logger: DydxLogger override fun onCreate() { super.onCreate()