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
@@ -11,7 +11,8 @@ import android.os.Build
import eu.kanade.tachiyomi.extension.model.InstallStep
import eu.kanade.tachiyomi.util.lang.use
import eu.kanade.tachiyomi.util.system.getUriSize
import timber.log.Timber
import eu.kanade.tachiyomi.util.system.logcat
import logcat.LogPriority
class PackageInstallerInstaller(private val service: Service) : Installer(service) {
@@ -23,7 +24,7 @@ class PackageInstallerInstaller(private val service: Service) : Installer(servic
PackageInstaller.STATUS_PENDING_USER_ACTION -> {
val userAction = intent.getParcelableExtra<Intent>(Intent.EXTRA_INTENT)
if (userAction == null) {
Timber.e("Fatal error for $intent")
logcat(LogPriority.ERROR) { "Fatal error for $intent" }
continueQueue(InstallStep.Error)
return
}
@@ -74,7 +75,7 @@ class PackageInstallerInstaller(private val service: Service) : Installer(servic
session.commit(intentSender)
}
} catch (e: Exception) {
Timber.e(e, "Failed to install extension ${entry.downloadId} ${entry.uri}")
logcat(LogPriority.ERROR) { "Failed to install extension ${entry.downloadId} ${entry.uri}" }
activeSession?.let { (_, sessionId) ->
packageInstaller.abandonSession(sessionId)
}
@@ -6,14 +6,15 @@ import android.os.Build
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.extension.model.InstallStep
import eu.kanade.tachiyomi.util.system.getUriSize
import eu.kanade.tachiyomi.util.system.logcat
import eu.kanade.tachiyomi.util.system.toast
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancel
import kotlinx.coroutines.launch
import logcat.LogPriority
import rikka.shizuku.Shizuku
import timber.log.Timber
import java.io.BufferedReader
import java.io.InputStream
@@ -22,7 +23,7 @@ class ShizukuInstaller(private val service: Service) : Installer(service) {
private val ioScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
private val shizukuDeadListener = Shizuku.OnBinderDeadListener {
Timber.e("Shizuku was killed prematurely")
logcat { "Shizuku was killed prematurely" }
service.stopSelf()
}
@@ -72,7 +73,7 @@ class ShizukuInstaller(private val service: Service) : Installer(service) {
continueQueue(InstallStep.Installed)
}
} catch (e: Exception) {
Timber.e(e, "Failed to install extension ${entry.downloadId} ${entry.uri}")
logcat(LogPriority.ERROR, e) { "Failed to install extension ${entry.downloadId} ${entry.uri}" }
if (sessionId != null) {
exec("pm install-abandon $sessionId")
}
@@ -115,7 +116,7 @@ class ShizukuInstaller(private val service: Service) : Installer(service) {
false
}
} else {
Timber.e("Shizuku is not ready to use.")
logcat(LogPriority.ERROR) { "Shizuku is not ready to use." }
service.toast(R.string.ext_installer_shizuku_stopped)
service.stopSelf()
false