Replace Timber with Square Logcat and make logging configurable (#6062)

* Replace Timber with Square Logcat

* Configurable logger
This commit is contained in:
Ivan Iskandar
2021-10-08 09:12:55 +07:00
committed by GitHub
parent 828db19e02
commit 2e127dff1f
52 changed files with 223 additions and 142 deletions
@@ -87,6 +87,7 @@ import eu.kanade.tachiyomi.util.hasCustomCover
import eu.kanade.tachiyomi.util.lang.launchIO
import eu.kanade.tachiyomi.util.lang.launchUI
import eu.kanade.tachiyomi.util.storage.getUriCompat
import eu.kanade.tachiyomi.util.system.logcat
import eu.kanade.tachiyomi.util.system.toShareIntent
import eu.kanade.tachiyomi.util.system.toast
import eu.kanade.tachiyomi.util.view.getCoordinates
@@ -95,9 +96,9 @@ import eu.kanade.tachiyomi.util.view.snack
import eu.kanade.tachiyomi.widget.materialdialogs.QuadStateTextView
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import logcat.LogPriority
import reactivecircus.flowbinding.recyclerview.scrollStateChanges
import reactivecircus.flowbinding.swiperefreshlayout.refreshes
import timber.log.Timber
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy
@@ -595,7 +596,9 @@ class MangaController :
presenter.registerTracking(track, service as TrackService)
}
} catch (e: Exception) {
Timber.w(e, "Could not match manga: ${manga.title} with service $service")
logcat(LogPriority.WARN, e) {
"Could not match manga: ${manga.title} with service $service"
}
}
}
}
@@ -767,7 +770,7 @@ class MangaController :
startActivity(uri.toShareIntent(activity))
}
} catch (e: Exception) {
Timber.e(e)
logcat(LogPriority.ERROR, e)
activity?.toast(R.string.error_sharing_cover)
}
}
@@ -780,7 +783,7 @@ class MangaController :
activity.toast(R.string.cover_saved)
}
} catch (e: Exception) {
Timber.e(e)
logcat(LogPriority.ERROR, e)
activity?.toast(R.string.error_saving_cover)
}
}
@@ -836,7 +839,7 @@ class MangaController :
fun onSetCoverError(error: Throwable) {
activity?.toast(R.string.notification_cover_update_failed)
Timber.e(error)
logcat(LogPriority.ERROR, error)
}
/**
@@ -1177,7 +1180,7 @@ class MangaController :
}
fun onChaptersDeletedError(error: Throwable) {
Timber.e(error)
logcat(LogPriority.ERROR, error)
}
override fun startDownloadNow(position: Int) {
@@ -1231,7 +1234,7 @@ class MangaController :
}
fun onTrackingRefreshError(error: Throwable) {
Timber.e(error)
logcat(LogPriority.ERROR, error)
activity?.toast(error.message)
}
@@ -1240,7 +1243,7 @@ class MangaController :
}
fun onTrackingSearchResultsError(error: Throwable) {
Timber.e(error)
logcat(LogPriority.ERROR, error)
getTrackingSearchDialog()?.onSearchResultsError(error.message)
}
@@ -43,6 +43,7 @@ import eu.kanade.tachiyomi.util.storage.DiskUtil
import eu.kanade.tachiyomi.util.storage.getPicturesDir
import eu.kanade.tachiyomi.util.storage.getTempShareDir
import eu.kanade.tachiyomi.util.system.ImageUtil
import eu.kanade.tachiyomi.util.system.logcat
import eu.kanade.tachiyomi.util.system.toast
import eu.kanade.tachiyomi.util.updateCoverLastModified
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.State
@@ -50,11 +51,11 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.supervisorScope
import logcat.LogPriority
import rx.Observable
import rx.Subscription
import rx.android.schedulers.AndroidSchedulers
import rx.schedulers.Schedulers
import timber.log.Timber
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.io.File
@@ -128,7 +129,9 @@ class MangaPresenter(
getTrackingObservable()
.observeOn(AndroidSchedulers.mainThread())
.subscribeLatestCache(MangaController::onTrackingCount) { _, error -> Timber.e(error) }
.subscribeLatestCache(MangaController::onTrackingCount) { _, error ->
logcat(LogPriority.ERROR, error)
}
// Prepare the relay.
chaptersRelay.flatMap { applyChapterFilters(it) }
@@ -138,7 +141,7 @@ class MangaPresenter(
filteredAndSortedChapters = chapters
view?.onNextChapters(chapters)
},
{ _, error -> Timber.e(error) }
{ _, error -> logcat(LogPriority.ERROR, error) }
)
// Manga info - end
@@ -428,7 +431,7 @@ class MangaPresenter(
view.onChapterDownloadUpdate(it)
},
{ _, error ->
Timber.e(error)
logcat(LogPriority.ERROR, error)
}
)
@@ -439,7 +442,7 @@ class MangaPresenter(
.filter { download -> download.manga.id == manga.id }
.observeOn(AndroidSchedulers.mainThread())
.subscribeLatestCache(MangaController::onChapterDownloadUpdate) { _, error ->
Timber.e(error)
logcat(LogPriority.ERROR, error)
}
}