Skip to content

Commit

Permalink
Introduced Timber logger
Browse files Browse the repository at this point in the history
  • Loading branch information
jahudzik committed Oct 14, 2017
1 parent 9fab271 commit 1235934
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -23,7 +24,8 @@ class QuizSetupPresenter(

override fun onStartQuizButtonClicked() {
triviaService.getGeneralQuestions().enqueue(object : Callback<TriviaResponse> {
override fun onFailure(call: Call<TriviaResponse>?, t: Throwable?) {
override fun onFailure(call: Call<TriviaResponse>?, throwable: Throwable?) {
Timber.e(throwable, "Failed to fetch the questions")
// TODO handle failure
}

Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ext {

retrofitVersion = '2.3.0'

timberVersion = '4.5.1'
leakCanaryVersion = '1.5.4'
stethoVersion = '1.5.0'

Expand Down

0 comments on commit 1235934

Please sign in to comment.