Improve logging

This commit is contained in:
NerdNumber9
2019-04-14 10:09:43 -04:00
parent 5e13df9bd8
commit 863e349711
8 changed files with 121 additions and 9 deletions

View File

@@ -6,6 +6,7 @@ import android.content.Intent
import android.net.Uri
import android.os.IBinder
import android.os.PowerManager
import com.elvishew.xlog.XLog
import com.github.salomonbrys.kotson.fromJson
import com.google.gson.JsonArray
import com.google.gson.JsonParser
@@ -249,7 +250,10 @@ class BackupRestoreService : Service() {
}
.doOnError { error ->
Timber.e(error)
// [EXH]
XLog.w("> Failed to perform restore!", error)
XLog.w("> (uri: %s)", uri)
writeErrorLog()
val errorIntent = Intent(BackupConst.INTENT_FILTER).apply {
putExtra(BackupConst.ACTION, BackupConst.ACTION_ERROR_RESTORE_DIALOG)
@@ -322,6 +326,14 @@ class BackupRestoreService : Service() {
tracks: List<Track>): Observable<Manga> {
return backupManager.restoreMangaFetchObservable(source, manga)
.onErrorReturn {
// [EXH]
XLog.w("> Failed to restore manga!", it)
XLog.w("> (source.id: %s, source.name: %s, manga.id: %s, manga.url: %s)",
source.id,
source.name,
manga.id,
manga.url)
errors.add(Date() to "${manga.title} - ${it.message}")
manga
}
@@ -394,6 +406,15 @@ class BackupRestoreService : Service() {
return backupManager.restoreChapterFetchObservable(source, manga, chapters)
// If there's any error, return empty update and continue.
.onErrorReturn {
// [EXH]
XLog.w("> Failed to restore chapter!", it)
XLog.w("> (source.id: %s, source.name: %s, manga.id: %s, manga.url: %s, chapters.size: %s)",
source.id,
source.name,
manga.id,
manga.url,
chapters.size)
errors.add(Date() to "${manga.title} - ${it.message}")
Pair(emptyList(), emptyList())
}

View File

@@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.data.download
import android.content.Context
import android.webkit.MimeTypeMap
import com.elvishew.xlog.XLog
import com.hippo.unifile.UniFile
import com.jakewharton.rxrelay.BehaviorRelay
import com.jakewharton.rxrelay.PublishRelay
@@ -284,6 +285,16 @@ class Downloader(
.doOnNext { ensureSuccessfulDownload(download, mangaDir, tmpDir, chapterDirname) }
// If the page list threw, it will resume here
.onErrorReturn { error ->
// [EXH]
XLog.w("> Download error!", error)
XLog.w("> (source.id: %s, source.name: %s, manga.id: %s, manga.url: %s, chapter.id: %s, chapter.url: %s)",
download.source.id,
download.source.name,
download.manga.id,
download.manga.url,
download.chapter.id,
download.chapter.url)
download.status = Download.ERROR
notifier.onError(error.message, download.chapter.name)
download
@@ -355,6 +366,15 @@ class Downloader(
val extension = getImageExtension(response, file)
file.renameTo("$filename.$extension")
} catch (e: Exception) {
// [EXH]
XLog.w("> Failed to fetch image!", e)
XLog.w("> (source.id: %s, source.name: %s, page.index: %s, page.url: %s, page.imageUrl: %s)",
source.id,
source.name,
page.index,
page.url,
page.imageUrl)
response.close()
file.delete()
throw e