diff --git a/app/build.gradle b/app/build.gradle index 02494d9..f915630 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -47,6 +47,7 @@ dependencies { implementation "com.squareup.retrofit2:retrofit:$retrofitVersion" implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion" + implementation "com.jakewharton.timber:timber:$timberVersion" debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion" releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion" implementation "com.facebook.stetho:stetho:$stethoVersion" diff --git a/app/src/main/java/com/jahu/playground/PlaygroundApplication.kt b/app/src/main/java/com/jahu/playground/PlaygroundApplication.kt index 4e03e68..99744ca 100644 --- a/app/src/main/java/com/jahu/playground/PlaygroundApplication.kt +++ b/app/src/main/java/com/jahu/playground/PlaygroundApplication.kt @@ -7,6 +7,7 @@ import com.jahu.playground.trivia.TriviaService import com.squareup.leakcanary.LeakCanary import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory +import timber.log.Timber private const val TRIVIA_API_BASE_URL = "https://opentdb.com" @@ -22,11 +23,18 @@ class PlaygroundApplication : Application() { return } LeakCanary.install(this) + setupTimber() setupStetho() setupStrictMode() setupTriviaService() } + private fun setupTimber() { + if (BuildConfig.DEBUG) { + Timber.plant(Timber.DebugTree()) + } + } + private fun setupStetho() { if (BuildConfig.DEBUG) { Stetho.initializeWithDefaults(this) diff --git a/app/src/main/java/com/jahu/playground/features/quizsetup/QuizSetupPresenter.kt b/app/src/main/java/com/jahu/playground/features/quizsetup/QuizSetupPresenter.kt index d85fb5f..a626fd2 100644 --- a/app/src/main/java/com/jahu/playground/features/quizsetup/QuizSetupPresenter.kt +++ b/app/src/main/java/com/jahu/playground/features/quizsetup/QuizSetupPresenter.kt @@ -8,6 +8,7 @@ import com.jahu.playground.trivia.TriviaService import retrofit2.Call import retrofit2.Callback import retrofit2.Response +import timber.log.Timber class QuizSetupPresenter( private val view: QuizSetupContract.View, @@ -23,7 +24,8 @@ class QuizSetupPresenter( override fun onStartQuizButtonClicked() { triviaService.getGeneralQuestions().enqueue(object : Callback { - override fun onFailure(call: Call?, t: Throwable?) { + override fun onFailure(call: Call?, throwable: Throwable?) { + Timber.e(throwable, "Failed to fetch the questions") // TODO handle failure } diff --git a/build.gradle b/build.gradle index b5a0b51..3bce8e7 100644 --- a/build.gradle +++ b/build.gradle @@ -29,6 +29,7 @@ ext { retrofitVersion = '2.3.0' + timberVersion = '4.5.1' leakCanaryVersion = '1.5.4' stethoVersion = '1.5.0'