Update XLog

This commit is contained in:
Jobobby04 2020-11-25 15:57:05 -05:00
parent fcc2b1773b
commit 643aa377bf
30 changed files with 79 additions and 89 deletions

View File

@ -315,7 +315,7 @@ dependencies {
implementation 'com.google.firebase:firebase-crashlytics-ktx:17.3.0' implementation 'com.google.firebase:firebase-crashlytics-ktx:17.3.0'
// Better logging (EH) // Better logging (EH)
implementation 'com.elvishew:xlog:1.6.1' implementation 'com.elvishew:xlog:1.7.1'
// Debug utils (EH) // Debug utils (EH)
final def debug_overlay_version = '1.1.3' final def debug_overlay_version = '1.1.3'

View File

@ -115,15 +115,15 @@ open class App : Application(), LifecycleObserver {
try { try {
SSLContext.getInstance("TLSv1.2") SSLContext.getInstance("TLSv1.2")
} catch (e: NoSuchAlgorithmException) { } catch (e: NoSuchAlgorithmException) {
XLog.e("Could not install Android 7 broken SSL workaround!", e) XLog.tag("Init").e("Could not install Android 7 broken SSL workaround!", e)
} }
try { try {
ProviderInstaller.installIfNeeded(applicationContext) ProviderInstaller.installIfNeeded(applicationContext)
} catch (e: GooglePlayServicesRepairableException) { } catch (e: GooglePlayServicesRepairableException) {
XLog.e("Could not install Android 7 broken SSL workaround!", e) XLog.tag("Init").e("Could not install Android 7 broken SSL workaround!", e)
} catch (e: GooglePlayServicesNotAvailableException) { } catch (e: GooglePlayServicesNotAvailableException) {
XLog.e("Could not install Android 7 broken SSL workaround!", e) XLog.tag("Init").e("Could not install Android 7 broken SSL workaround!", e)
} }
} }
} }
@ -183,8 +183,8 @@ open class App : Application(), LifecycleObserver {
val logConfig = LogConfiguration.Builder() val logConfig = LogConfiguration.Builder()
.logLevel(logLevel) .logLevel(logLevel)
.st(2) .disableStackTrace()
.nb() .disableBorder()
.build() .build()
val printers = mutableListOf<Printer>(AndroidPrinter()) val printers = mutableListOf<Printer>(AndroidPrinter())
@ -227,8 +227,8 @@ open class App : Application(), LifecycleObserver {
*printers.toTypedArray() *printers.toTypedArray()
) )
XLog.d("Application booting...") XLog.tag("Init").d("Application booting...")
XLog.nst().d( XLog.tag("Init").disableStackTrace().d(
"App version: ${BuildConfig.VERSION_NAME} (${BuildConfig.FLAVOR}, ${BuildConfig.COMMIT_SHA}, ${BuildConfig.VERSION_CODE})\n" + "App version: ${BuildConfig.VERSION_NAME} (${BuildConfig.FLAVOR}, ${BuildConfig.COMMIT_SHA}, ${BuildConfig.VERSION_CODE})\n" +
"Preview build: $syDebugVersion\n" + "Preview build: $syDebugVersion\n" +
"Android version: ${Build.VERSION.RELEASE} (SDK ${Build.VERSION.SDK_INT}) \n" + "Android version: ${Build.VERSION.RELEASE} (SDK ${Build.VERSION.SDK_INT}) \n" +
@ -253,7 +253,7 @@ open class App : Application(), LifecycleObserver {
.install() .install()
} catch (e: IllegalStateException) { } catch (e: IllegalStateException) {
// Crashes if app is in background // Crashes if app is in background
XLog.e("Failed to initialize debug overlay, app in background?", e) XLog.tag("Init").e("Failed to initialize debug overlay, app in background?", e)
} }
} }
} }

View File

@ -462,7 +462,7 @@ class LibraryUpdateService(
db.insertTrack(track).executeAsBlocking() db.insertTrack(track).executeAsBlocking()
} }
} catch (e: Exception) { } catch (e: Exception) {
XLog.e(e) XLog.tag("LibraryUpdateService").e(e)
} }
} }
} }

View File

@ -158,7 +158,7 @@ class ExtensionManager(
val blacklistEnabled = preferences.eh_enableSourceBlacklist().get() val blacklistEnabled = preferences.eh_enableSourceBlacklist().get()
return filter { return filter {
if (it.isBlacklisted(blacklistEnabled)) { if (it.isBlacklisted(blacklistEnabled)) {
XLog.d("[EXH] Removing blacklisted extension: (name: %s, pkgName: %s)!", it.name, it.pkgName) XLog.tag("ExtensionManager").d("Removing blacklisted extension: (name: %s, pkgName: %s)!", it.name, it.pkgName)
false false
} else true } else true
} }
@ -336,7 +336,7 @@ class ExtensionManager(
private fun registerNewExtension(extension: Extension.Installed) { private fun registerNewExtension(extension: Extension.Installed) {
// SY --> // SY -->
if (extension.isBlacklisted()) { if (extension.isBlacklisted()) {
XLog.d("[EXH] Removing blacklisted extension: (name: String, pkgName: %s)!", extension.name, extension.pkgName) XLog.tag("ExtensionManager").d("Removing blacklisted extension: (name: String, pkgName: %s)!", extension.name, extension.pkgName)
return return
} }
// SY <-- // SY <--
@ -354,7 +354,7 @@ class ExtensionManager(
private fun registerUpdatedExtension(extension: Extension.Installed) { private fun registerUpdatedExtension(extension: Extension.Installed) {
// SY --> // SY -->
if (extension.isBlacklisted()) { if (extension.isBlacklisted()) {
XLog.d("[EXH] Removing blacklisted extension: (name: String, pkgName: %s)!", extension.name, extension.pkgName) XLog.tag("ExtensionManager").d("Removing blacklisted extension: (name: String, pkgName: %s)!", extension.name, extension.pkgName)
return return
} }
// SY <-- // SY <--

View File

@ -114,7 +114,7 @@ open class SourceManager(private val context: Context) {
} else DELEGATED_SOURCES[sourceQName] } else DELEGATED_SOURCES[sourceQName]
} else null } else null
val newSource = if (source is HttpSource && delegate != null) { val newSource = if (source is HttpSource && delegate != null) {
XLog.d("[EXH] Delegating source: %s -> %s!", sourceQName, delegate.newSourceClass.qualifiedName) XLog.tag("SourceManager").d("Delegating source: %s -> %s!", sourceQName, delegate.newSourceClass.qualifiedName)
val enhancedSource = EnhancedHttpSource( val enhancedSource = EnhancedHttpSource(
source, source,
delegate.newSourceClass.constructors.find { it.parameters.size == 2 }!!.call(source, context) delegate.newSourceClass.constructors.find { it.parameters.size == 2 }!!.call(source, context)
@ -125,7 +125,7 @@ open class SourceManager(private val context: Context) {
} else source } else source
if (source.id in BlacklistedSources.BLACKLISTED_EXT_SOURCES) { if (source.id in BlacklistedSources.BLACKLISTED_EXT_SOURCES) {
XLog.d("[EXH] Removing blacklisted source: (id: %s, name: %s, lang: %s)!", source.id, source.name, (source as? CatalogueSource)?.lang) XLog.tag("SourceManager").d("Removing blacklisted source: (id: %s, name: %s, lang: %s)!", source.id, source.name, (source as? CatalogueSource)?.lang)
return return
} }
// EXH <-- // EXH <--

View File

@ -5,14 +5,12 @@ import eu.kanade.tachiyomi.data.database.DatabaseHelper
import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.data.database.models.Chapter
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.manga.MangaController
import exh.metadata.metadata.base.RaisedSearchMetadata import exh.metadata.metadata.base.RaisedSearchMetadata
import exh.metadata.metadata.base.getFlatMetadataForManga import exh.metadata.metadata.base.getFlatMetadataForManga
import exh.metadata.metadata.base.insertFlatMetadata import exh.metadata.metadata.base.insertFlatMetadata
import exh.source.EnhancedHttpSource
import rx.Completable import rx.Completable
import rx.Single import rx.Single
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
@ -49,7 +47,7 @@ interface MetadataSource<M : RaisedSearchMetadata, I> : CatalogueSource {
* Will also save the metadata to the DB if possible * Will also save the metadata to the DB if possible
*/ */
fun parseToManga(manga: SManga, input: I): Completable { fun parseToManga(manga: SManga, input: I): Completable {
val mangaId = (manga as? Manga)?.id val mangaId = manga.id
val metaObservable = if (mangaId != null) { val metaObservable = if (mangaId != null) {
// We have to use fromCallable because StorIO messes up the thread scheduling if we use their rx functions // We have to use fromCallable because StorIO messes up the thread scheduling if we use their rx functions
Single.fromCallable { Single.fromCallable {
@ -109,17 +107,4 @@ interface MetadataSource<M : RaisedSearchMetadata, I> : CatalogueSource {
val SManga.id get() = (this as? Manga)?.id val SManga.id get() = (this as? Manga)?.id
val SChapter.mangaId get() = (this as? Chapter)?.manga_id val SChapter.mangaId get() = (this as? Chapter)?.manga_id
companion object {
fun Source.isMetadataSource() = (this is MetadataSource<*, *> || (this is EnhancedHttpSource && this.enhancedSource is MetadataSource<*, *>))
fun Source.getMetadataSource(): MetadataSource<*, *>? {
return when {
!this.isMetadataSource() -> null
this is MetadataSource<*, *> -> this
this is EnhancedHttpSource && this.enhancedSource is MetadataSource<*, *> -> this.enhancedSource
else -> null
}
}
}
} }

View File

@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.source.online.all
import android.content.Context import android.content.Context
import android.net.Uri import android.net.Uri
import androidx.core.net.toUri
import com.elvishew.xlog.XLog import com.elvishew.xlog.XLog
import eu.kanade.tachiyomi.annoations.Nsfw import eu.kanade.tachiyomi.annoations.Nsfw
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
@ -313,7 +314,7 @@ class EHentai(
url = EHentaiSearchMetadata.normalizeUrl(parentLink) url = EHentaiSearchMetadata.normalizeUrl(parentLink)
} else break } else break
} else { } else {
XLog.d("Parent cache hit: %s!", gid) XLog.tag("EHentai").d("Parent cache hit: %s!", gid)
url = EHentaiSearchMetadata.idAndTokenToUrl( url = EHentaiSearchMetadata.idAndTokenToUrl(
cachedParent.gId, cachedParent.gId,
cachedParent.gToken cachedParent.gToken
@ -412,7 +413,7 @@ class EHentai(
} }
private fun searchMangaRequestObservable(page: Int, query: String, filters: FilterList): Observable<Request> { private fun searchMangaRequestObservable(page: Int, query: String, filters: FilterList): Observable<Request> {
val uri = Uri.parse("$baseUrl$QUERY_PREFIX").buildUpon() val uri = "$baseUrl$QUERY_PREFIX".toUri().buildUpon()
uri.appendQueryParameter("f_search", (query + " " + combineQuery(filters)).trim()) uri.appendQueryParameter("f_search", (query + " " + combineQuery(filters)).trim())
filters.forEach { filters.forEach {
@ -576,7 +577,7 @@ class EHentai(
lastUpdateCheck - datePosted!! > EHentaiUpdateWorkerConstants.GALLERY_AGE_TIME lastUpdateCheck - datePosted!! > EHentaiUpdateWorkerConstants.GALLERY_AGE_TIME
) { ) {
aged = true aged = true
XLog.d("aged %s - too old", title) XLog.tag("EHentai").d("aged %s - too old", title)
} }
// Parse ratings // Parse ratings
@ -723,7 +724,7 @@ class EHentai(
// Headers // Headers
override fun headersBuilder() = super.headersBuilder().add("Cookie", cookiesHeader()) override fun headersBuilder() = super.headersBuilder().add("Cookie", cookiesHeader())
private fun addParam(url: String, param: String, value: String) = Uri.parse(url) private fun addParam(url: String, param: String, value: String) = url.toUri()
.buildUpon() .buildUpon()
.appendQueryParameter(param, value) .appendQueryParameter(param, value)
.toString() .toString()
@ -842,7 +843,7 @@ class EHentai(
stringBuilder.append(" ") stringBuilder.append(" ")
} }
XLog.d(stringBuilder.toString()) XLog.tag("EHentai").d(stringBuilder.toString())
return stringBuilder.toString().trim() return stringBuilder.toString().trim()
} }

View File

@ -179,7 +179,7 @@ class MergedSource : SuspendHttpSource() {
reference.mangaId = manga.id reference.mangaId = manga.id
db.insertNewMergedMangaId(reference).await() db.insertNewMergedMangaId(reference).await()
} catch (e: Exception) { } catch (e: Exception) {
XLog.st(e.stackTrace.contentToString(), 5) XLog.tag("MergedSource").enableStackTrace(e.stackTrace.contentToString(), 5)
} }
} }
return LoadedMangaSource(source, manga, reference) return LoadedMangaSource(source, manga, reference)

View File

@ -538,8 +538,8 @@ open class BrowseSourceController(bundle: Bundle) :
*/ */
/* SY --> */ open /* SY <-- */fun onAddPageError(error: Throwable) { /* SY --> */ open /* SY <-- */fun onAddPageError(error: Throwable) {
// SY --> // SY -->
XLog.w("> Failed to load next catalogue page!", error) XLog.tag("BrowseSourceController").enableStackTrace(2).w("> Failed to load next catalogue page!", error)
XLog.w( XLog.tag("BrowseSourceController").enableStackTrace(2).w(
"> (source.id: %s, source.name: %s)", "> (source.id: %s, source.name: %s)",
presenter.source.id, presenter.source.id,
presenter.source.name presenter.source.name

View File

@ -97,7 +97,7 @@ open class AutoComplete(val filter: Filter.AutoComplete) : AbstractFlexibleItem<
addChipToGroup(name, holder) addChipToGroup(name, holder)
filter.state += name filter.state += name
} else { } else {
XLog.d("Invalid tag: $name") XLog.tag("AutoComplete").d("Invalid tag: $name")
} }
} }

View File

@ -48,9 +48,9 @@ class BiometricTimesCreateDialog<T>(bundle: Bundle? = null) : DialogController(b
.title(if (startTime == null) R.string.biometric_lock_start_time else R.string.biometric_lock_end_time) .title(if (startTime == null) R.string.biometric_lock_start_time else R.string.biometric_lock_end_time)
.timePicker(show24HoursView = false) { _, datetime -> .timePicker(show24HoursView = false) { _, datetime ->
val hour = datetime.get(Calendar.HOUR_OF_DAY) val hour = datetime.get(Calendar.HOUR_OF_DAY)
XLog.nst().d(hour) XLog.disableStackTrace().d(hour)
val minute = datetime.get(Calendar.MINUTE) val minute = datetime.get(Calendar.MINUTE)
XLog.nst().d(minute) XLog.disableStackTrace().d(minute)
if (hour !in 0..24 || minute !in 0..60) return@timePicker if (hour !in 0..24 || minute !in 0..60) return@timePicker
if (startTime != null) { if (startTime != null) {
endTime = hour.hours + minute.minutes endTime = hour.hours + minute.minutes

View File

@ -41,7 +41,7 @@ class BiometricTimesPresenter : BasePresenter<BiometricTimesController>() {
preferences.biometricTimeRanges().asFlow().onEach { prefTimeRanges -> preferences.biometricTimeRanges().asFlow().onEach { prefTimeRanges ->
timeRanges = prefTimeRanges.toList() timeRanges = prefTimeRanges.toList()
.mapNotNull { TimeRange.fromPreferenceString(it) }.onEach { XLog.nst().d(it) } .mapNotNull { TimeRange.fromPreferenceString(it) }.onEach { XLog.disableStackTrace().d(it) }
Observable.just(timeRanges) Observable.just(timeRanges)
.map { it.map(::BiometricTimesItem) } .map { it.map(::BiometricTimesItem) }
@ -62,7 +62,7 @@ class BiometricTimesPresenter : BasePresenter<BiometricTimesController>() {
return return
} }
XLog.nst().d(timeRange) XLog.disableStackTrace().d(timeRange)
preferences.biometricTimeRanges() += timeRange.toPreferenceString() preferences.biometricTimeRanges() += timeRange.toPreferenceString()
} }

View File

@ -74,7 +74,7 @@ class EditMergedSettingsHeaderAdapter(private val controller: EditMergedSettings
3 -> MergedMangaReference.CHAPTER_SORT_HIGHEST_CHAPTER_NUMBER 3 -> MergedMangaReference.CHAPTER_SORT_HIGHEST_CHAPTER_NUMBER
else -> MergedMangaReference.CHAPTER_SORT_NO_DEDUPE else -> MergedMangaReference.CHAPTER_SORT_NO_DEDUPE
} }
XLog.nst().d(controller.mergeReference?.chapterSortMode) XLog.d(controller.mergeReference?.chapterSortMode)
editMergedMangaItemSortingListener.onSetPrioritySort(canMove()) editMergedMangaItemSortingListener.onSetPrioritySort(canMove())
} }

View File

@ -319,7 +319,7 @@ object EXHMigrations {
try { try {
dbLocation.copyTo(backupLocation, overwrite = true) dbLocation.copyTo(backupLocation, overwrite = true)
} catch (t: Throwable) { } catch (t: Throwable) {
XLog.w("Failed to backup database!") logger.enableStackTrace(2).w("Failed to backup database!")
} }
} }

View File

@ -22,6 +22,8 @@ class GalleryAdder {
private val sourceManager: SourceManager by injectLazy() private val sourceManager: SourceManager by injectLazy()
private val logger = XLog.tag("GalleryAdder").enableStackTrace(2).build()
fun pickSource(url: String): List<UrlImportableSource> { fun pickSource(url: String): List<UrlImportableSource> {
val uri = url.toUri() val uri = url.toUri()
return sourceManager.getVisibleCatalogueSources() return sourceManager.getVisibleCatalogueSources()
@ -43,7 +45,7 @@ class GalleryAdder {
forceSource: UrlImportableSource? = null, forceSource: UrlImportableSource? = null,
throttleFunc: () -> Unit = {} throttleFunc: () -> Unit = {}
): GalleryAddEvent { ): GalleryAddEvent {
XLog.d(context.getString(R.string.gallery_adder_importing_manga, url, fav.toString(), forceSource)) logger.d(context.getString(R.string.gallery_adder_importing_manga, url, fav.toString(), forceSource))
try { try {
val uri = url.toUri() val uri = url.toUri()
@ -53,7 +55,7 @@ class GalleryAdder {
if (forceSource.matchesUri(uri)) forceSource if (forceSource.matchesUri(uri)) forceSource
else return GalleryAddEvent.Fail.UnknownType(url, context) else return GalleryAddEvent.Fail.UnknownType(url, context)
} catch (e: Exception) { } catch (e: Exception) {
XLog.e(context.getString(R.string.gallery_adder_source_uri_must_match), e) logger.e(context.getString(R.string.gallery_adder_source_uri_must_match), e)
return GalleryAddEvent.Fail.UnknownType(url, context) return GalleryAddEvent.Fail.UnknownType(url, context)
} }
} else { } else {
@ -73,7 +75,7 @@ class GalleryAdder {
val realUrl = try { val realUrl = try {
source.mapUrlToMangaUrl(uri) source.mapUrlToMangaUrl(uri)
} catch (e: Exception) { } catch (e: Exception) {
XLog.e(context.getString(R.string.gallery_adder_uri_map_to_manga_error), e) logger.e(context.getString(R.string.gallery_adder_uri_map_to_manga_error), e)
null null
} ?: return GalleryAddEvent.Fail.UnknownType(url, context) } ?: return GalleryAddEvent.Fail.UnknownType(url, context)
@ -81,7 +83,7 @@ class GalleryAdder {
val cleanedUrl = try { val cleanedUrl = try {
source.cleanMangaUrl(realUrl) source.cleanMangaUrl(realUrl)
} catch (e: Exception) { } catch (e: Exception) {
XLog.e(context.getString(R.string.gallery_adder_uri_clean_error), e) logger.e(context.getString(R.string.gallery_adder_uri_clean_error), e)
null null
} ?: return GalleryAddEvent.Fail.UnknownType(url, context) } ?: return GalleryAddEvent.Fail.UnknownType(url, context)
@ -125,13 +127,13 @@ class GalleryAdder {
} else emptyList<Chapter>() to emptyList() } else emptyList<Chapter>() to emptyList()
}.awaitSingle() }.awaitSingle()
} catch (e: Exception) { } catch (e: Exception) {
XLog.w(context.getString(R.string.gallery_adder_chapter_fetch_error, manga.title), e) logger.w(context.getString(R.string.gallery_adder_chapter_fetch_error, manga.title), e)
return GalleryAddEvent.Fail.Error(url, context.getString(R.string.gallery_adder_chapter_fetch_error, url)) return GalleryAddEvent.Fail.Error(url, context.getString(R.string.gallery_adder_chapter_fetch_error, url))
} }
return GalleryAddEvent.Success(url, manga, context) return GalleryAddEvent.Success(url, manga, context)
} catch (e: Exception) { } catch (e: Exception) {
XLog.w(context.getString(R.string.gallery_adder_could_not_add_manga, url), e) logger.w(context.getString(R.string.gallery_adder_could_not_add_manga, url), e)
if (e is EHentai.GalleryNotFoundException) { if (e is EHentai.GalleryNotFoundException) {
return GalleryAddEvent.Fail.NotFound(url, context) return GalleryAddEvent.Fail.NotFound(url, context)

View File

@ -30,6 +30,7 @@ import kotlinx.serialization.json.Json
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.lang.RuntimeException import java.lang.RuntimeException
@Suppress("unused")
object DebugFunctions { object DebugFunctions {
val app: Application by injectLazy() val app: Application by injectLazy()
val db: DatabaseHelper by injectLazy() val db: DatabaseHelper by injectLazy()
@ -239,7 +240,7 @@ object DebugFunctions {
Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':')) Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':'))
} catch (t: RuntimeException) { } catch (t: RuntimeException) {
// Load failed // Load failed
XLog.e("Failed to load saved search!", t) XLog.tag("DebugFunctions").e("Failed to load saved search!", t)
t.printStackTrace() t.printStackTrace()
null null
} }
@ -251,7 +252,7 @@ object DebugFunctions {
Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':')) Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':'))
} catch (t: RuntimeException) { } catch (t: RuntimeException) {
// Load failed // Load failed
XLog.e("Failed to load saved search!", t) XLog.tag("DebugFunctions").e("Failed to load saved search!", t)
t.printStackTrace() t.printStackTrace()
null null
} }
@ -278,7 +279,7 @@ object DebugFunctions {
Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':')) Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':'))
} catch (t: RuntimeException) { } catch (t: RuntimeException) {
// Load failed // Load failed
XLog.e("Failed to load saved search!", t) XLog.tag("DebugFunctions").e("Failed to load saved search!", t)
t.printStackTrace() t.printStackTrace()
null null
} }
@ -290,7 +291,7 @@ object DebugFunctions {
Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':')) Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':'))
} catch (t: RuntimeException) { } catch (t: RuntimeException) {
// Load failed // Load failed
XLog.e("Failed to load saved search!", t) XLog.tag("DebugFunctions").e("Failed to load saved search!", t)
t.printStackTrace() t.printStackTrace()
null null
} }

View File

@ -93,7 +93,7 @@ class MemAutoFlushingLookupTable<T>(
} }
} }
} catch (e: FileNotFoundException) { } catch (e: FileNotFoundException) {
XLog.d("Lookup table not found!", e) XLog.tag("MemAutoFlushingLookupTable").enableStackTrace(2).d("Lookup table not found!", e)
// Ignored // Ignored
} }

View File

@ -11,9 +11,9 @@ fun OkHttpClient.Builder.maybeInjectEHLogger(): OkHttpClient.Builder {
val logger: HttpLoggingInterceptor.Logger = HttpLoggingInterceptor.Logger { message -> val logger: HttpLoggingInterceptor.Logger = HttpLoggingInterceptor.Logger { message ->
try { try {
Json.decodeFromString<Any>(message) Json.decodeFromString<Any>(message)
XLog.tag("||EH-NETWORK-JSON").nst().json(message) XLog.tag("||EH-NETWORK-JSON").json(message)
} catch (ex: Exception) { } catch (ex: Exception) {
XLog.tag("||EH-NETWORK").nb().nst().d(message) XLog.tag("||EH-NETWORK").disableBorder().d(message)
} }
} }
return addInterceptor(HttpLoggingInterceptor(logger).apply { level = HttpLoggingInterceptor.Level.BODY }) return addInterceptor(HttpLoggingInterceptor(logger).apply { level = HttpLoggingInterceptor.Level.BODY })

View File

@ -1,6 +1,5 @@
package exh.log package exh.log
import com.elvishew.xlog.flattener.Flattener2
import com.elvishew.xlog.internal.DefaultsFactory import com.elvishew.xlog.internal.DefaultsFactory
import com.elvishew.xlog.printer.Printer import com.elvishew.xlog.printer.Printer
import com.elvishew.xlog.printer.file.backup.BackupStrategy import com.elvishew.xlog.printer.file.backup.BackupStrategy
@ -12,6 +11,7 @@ import java.io.FileWriter
import java.io.IOException import java.io.IOException
import java.util.concurrent.BlockingQueue import java.util.concurrent.BlockingQueue
import java.util.concurrent.LinkedBlockingQueue import java.util.concurrent.LinkedBlockingQueue
import com.elvishew.xlog.flattener.Flattener2 as Flattener
/** /**
* Log [Printer] using file system. When print a log, it will print it to the specified file. * Log [Printer] using file system. When print a log, it will print it to the specified file.
@ -31,7 +31,7 @@ class EnhancedFilePrinter internal constructor(
private val fileNameGenerator: FileNameGenerator, private val fileNameGenerator: FileNameGenerator,
private val backupStrategy: BackupStrategy, private val backupStrategy: BackupStrategy,
private val cleanStrategy: CleanStrategy, private val cleanStrategy: CleanStrategy,
private val flattener: Flattener2 private val flattener: Flattener
) : Printer { ) : Printer {
/** /**
* Log writer. * Log writer.
@ -134,7 +134,7 @@ class EnhancedFilePrinter internal constructor(
/** /**
* The flattener when print a log. * The flattener when print a log.
*/ */
private var flattener: Flattener2? = null private var flattener: Flattener? = null
/** /**
* Set the file name generator for log file. * Set the file name generator for log file.
@ -174,9 +174,8 @@ class EnhancedFilePrinter internal constructor(
* *
* @param flattener the flattener when print a log * @param flattener the flattener when print a log
* @return the builder * @return the builder
* @since 1.6.0
*/ */
fun flattener(flattener: Flattener2): Builder { fun flattener(flattener: Flattener): Builder {
this.flattener = flattener this.flattener = flattener
return this return this
} }
@ -187,11 +186,13 @@ class EnhancedFilePrinter internal constructor(
* @return the built configured [EnhancedFilePrinter] object * @return the built configured [EnhancedFilePrinter] object
*/ */
fun build(): EnhancedFilePrinter { fun build(): EnhancedFilePrinter {
val fileNameGenerator = fileNameGenerator ?: DefaultsFactory.createFileNameGenerator() return EnhancedFilePrinter(
val backupStrategy = backupStrategy ?: DefaultsFactory.createBackupStrategy() folderPath,
val cleanStrategy = cleanStrategy ?: DefaultsFactory.createCleanStrategy() fileNameGenerator ?: DefaultsFactory.createFileNameGenerator(),
val flattener = flattener ?: DefaultsFactory.createFlattener2() backupStrategy ?: DefaultsFactory.createBackupStrategy(),
return EnhancedFilePrinter(folderPath, fileNameGenerator, backupStrategy, cleanStrategy, flattener) cleanStrategy ?: DefaultsFactory.createCleanStrategy(),
flattener ?: DefaultsFactory.createFlattener2()
)
} }
} }
@ -244,8 +245,8 @@ class EnhancedFilePrinter internal constructor(
} }
override fun run() { override fun run() {
var log: LogItem
try { try {
var log: LogItem
while (logs.take().also { log = it } != null) { while (logs.take().also { log = it } != null) {
doPrintln(log.timeMillis, log.level, log.tag, log.msg) doPrintln(log.timeMillis, log.level, log.tag, log.msg)
} }
@ -341,7 +342,7 @@ class EnhancedFilePrinter internal constructor(
*/ */
fun appendLog(flattenedLog: String) { fun appendLog(flattenedLog: String) {
val bufferedWriter = bufferedWriter val bufferedWriter = bufferedWriter
require(bufferedWriter != null) requireNotNull(bufferedWriter)
try { try {
bufferedWriter.write(flattenedLog) bufferedWriter.write(flattenedLog)
bufferedWriter.newLine() bufferedWriter.newLine()

View File

@ -129,7 +129,7 @@ class ApiMangaParser(private val langs: List<String>) {
if (tags.isNotEmpty()) tags.clear() if (tags.isNotEmpty()) tags.clear()
tags += genres.map { RaisedTag(null, it, MangaDexSearchMetadata.TAG_TYPE_DEFAULT) } tags += genres.map { RaisedTag(null, it, MangaDexSearchMetadata.TAG_TYPE_DEFAULT) }
} catch (e: Exception) { } catch (e: Exception) {
XLog.e(e) XLog.tag("ApiMangaParser").enableStackTrace(2).e(e)
throw e throw e
} }
} }
@ -239,7 +239,7 @@ class ApiMangaParser(private val langs: List<String>) {
val jsonObject = Json.decodeFromString<JsonObject>(body) val jsonObject = Json.decodeFromString<JsonObject>(body)
return jsonObject["manga_id"]?.jsonPrimitive?.intOrNull ?: throw Exception("No manga associated with chapter") return jsonObject["manga_id"]?.jsonPrimitive?.intOrNull ?: throw Exception("No manga associated with chapter")
} catch (e: Exception) { } catch (e: Exception) {
XLog.e(e) XLog.tag("ApiMangaParser").enableStackTrace(2).e(e)
throw e throw e
} }
} }

View File

@ -51,7 +51,7 @@ class FollowsHandler(val client: OkHttpClient, val headers: Headers, val prefere
response.body?.string().orEmpty() response.body?.string().orEmpty()
) )
} catch (e: Exception) { } catch (e: Exception) {
XLog.e("error parsing follows", e) XLog.tag("FollowsHandler").enableStackTrace(2).e("error parsing follows", e)
FollowsPageResult() FollowsPageResult()
} }
@ -81,7 +81,7 @@ class FollowsHandler(val client: OkHttpClient, val headers: Headers, val prefere
response.body?.string().orEmpty() response.body?.string().orEmpty()
) )
} catch (e: Exception) { } catch (e: Exception) {
XLog.e("error parsing follows", e) XLog.tag("FollowsHandler").enableStackTrace(2).e("error parsing follows", e)
FollowsPageResult() FollowsPageResult()
} }
val track = Track.create(TrackManager.MDLIST) val track = Track.create(TrackManager.MDLIST)
@ -158,7 +158,7 @@ class FollowsHandler(val client: OkHttpClient, val headers: Headers, val prefere
val mangaID = MdUtil.getMangaId(track.tracking_url) val mangaID = MdUtil.getMangaId(track.tracking_url)
val formBody = FormBody.Builder() val formBody = FormBody.Builder()
.add("chapter", track.last_chapter_read.toString()) .add("chapter", track.last_chapter_read.toString())
XLog.d("chapter to update %s", track.last_chapter_read.toString()) XLog.tag("FollowsHandler").d("chapter to update %s", track.last_chapter_read.toString())
val response = client.newCall( val response = client.newCall(
POST( POST(
"${MdUtil.baseUrl}/ajax/actions.ajax.php?function=edit_progress&id=$mangaID", "${MdUtil.baseUrl}/ajax/actions.ajax.php?function=edit_progress&id=$mangaID",

View File

@ -27,7 +27,7 @@ class MangaHandler(val client: OkHttpClient, val headers: Headers, val langs: Li
val jsonData = withContext(Dispatchers.IO) { response.body!!.string() } val jsonData = withContext(Dispatchers.IO) { response.body!!.string() }
if (response.code != 200) { if (response.code != 200) {
XLog.e("error from MangaDex with response code ${response.code} \n body: \n$jsonData") XLog.tag("MangaHandler").enableStackTrace(2).e("error from MangaDex with response code ${response.code} \n body: \n$jsonData")
throw Exception("Error from MangaDex Response code ${response.code} ") throw Exception("Error from MangaDex Response code ${response.code} ")
} }

View File

@ -118,7 +118,7 @@ class SimilarUpdateService(
// Unsubscribe from any previous subscription if needed. // Unsubscribe from any previous subscription if needed.
job?.cancel() job?.cancel()
val handler = CoroutineExceptionHandler { _, exception -> val handler = CoroutineExceptionHandler { _, exception ->
XLog.e(exception) XLog.tag("SimilarUpdateService").enableStackTrace(2).e(exception)
stopSelf(startId) stopSelf(startId)
showResultNotification(true) showResultNotification(true)
cancelProgressNotification() cancelProgressNotification()

View File

@ -37,7 +37,7 @@ class ConfiguringDialogController : DialogController() {
.show() .show()
} }
} }
XLog.e("Configuration error!", e) XLog.tag("ConfiguringDialogController").enableStackTrace(2).e("Configuration error!", e)
} }
launchUI { launchUI {
finish() finish()

View File

@ -81,7 +81,7 @@ class EHConfigurator(val context: Context) {
} }
} }
XLog.nst().d("Hath perks: $hathPerks") XLog.tag("EHConfigurator").d("Hath perks: $hathPerks")
configure(ehSource, hathPerks) configure(ehSource, hathPerks)
configure(exhSource, hathPerks) configure(exhSource, hathPerks)

View File

@ -59,7 +59,7 @@ class BatchAddPresenter : BasePresenter<BatchAddController>() {
currentlyAddingRelay.call(STATE_INPUT_TO_PROGRESS) currentlyAddingRelay.call(STATE_INPUT_TO_PROGRESS)
val handler = CoroutineExceptionHandler { _, throwable -> val handler = CoroutineExceptionHandler { _, throwable ->
XLog.e(throwable) XLog.tag("BatchAddPresenter").enableStackTrace(2).e(throwable)
} }
scope.launch(Dispatchers.IO + handler) { scope.launch(Dispatchers.IO + handler) {

View File

@ -187,7 +187,7 @@ class BrowserActionActivity : AppCompatActivity() {
suspend fun captchaSolveFail() { suspend fun captchaSolveFail() {
currentLoopId = null currentLoopId = null
validateCurrentLoopId = null validateCurrentLoopId = null
XLog.e(IllegalStateException("Captcha solve failure!")) XLog.tag("BrowserActionActivity").enableStackTrace(2).e(IllegalStateException("Captcha solve failure!"))
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
binding.webview.evaluateJavascript(SOLVE_UI_SCRIPT_HIDE, null) binding.webview.evaluateJavascript(SOLVE_UI_SCRIPT_HIDE, null)
MaterialDialog(this@BrowserActionActivity) MaterialDialog(this@BrowserActionActivity)
@ -231,7 +231,7 @@ class BrowserActionActivity : AppCompatActivity() {
val ih = splitResult[3] val ih = splitResult[3]
val x = binding.webview.x + origX / iw * binding.webview.width val x = binding.webview.x + origX / iw * binding.webview.width
val y = binding.webview.y + origY / ih * binding.webview.height val y = binding.webview.y + origY / ih * binding.webview.height
XLog.nst().d("Found audio button coords: %f %f", x, y) XLog.tag("BrowserActionActivity").d("Found audio button coords: %f %f", x, y)
simulateClick(x + 50, y + 50) simulateClick(x + 50, y + 50)
binding.webview.post { binding.webview.post {
doStageDownloadAudio(loopId) doStageDownloadAudio(loopId)
@ -247,12 +247,12 @@ class BrowserActionActivity : AppCompatActivity() {
} }
STAGE_DOWNLOAD_AUDIO -> { STAGE_DOWNLOAD_AUDIO -> {
if (result != null) { if (result != null) {
XLog.nst().d("Got audio URL: $result") XLog.tag("BrowserActionActivity").d("Got audio URL: $result")
performRecognize(result) performRecognize(result)
.observeOn(Schedulers.io()) .observeOn(Schedulers.io())
.subscribe( .subscribe(
{ {
XLog.nst().d("Got audio transcript: $it") XLog.tag("BrowserActionActivity").d("Got audio transcript: $it")
binding.webview.post { binding.webview.post {
typeResult( typeResult(
loopId, loopId,
@ -465,7 +465,7 @@ class BrowserActionActivity : AppCompatActivity() {
if (loopId != validateCurrentLoopId) return if (loopId != validateCurrentLoopId) return
if (result) { if (result) {
XLog.nst().d("Captcha solved!") XLog.tag("BrowserActionActivity").d("Captcha solved!")
binding.webview.post { binding.webview.post {
binding.webview.evaluateJavascript(SOLVE_UI_SCRIPT_HIDE, null) binding.webview.evaluateJavascript(SOLVE_UI_SCRIPT_HIDE, null)
} }

View File

@ -91,7 +91,7 @@ class LoginController : NucleusController<EhActivityLoginBinding, LoginPresenter
binding.webview.webViewClient = object : WebViewClient() { binding.webview.webViewClient = object : WebViewClient() {
override fun onPageFinished(view: WebView, url: String) { override fun onPageFinished(view: WebView, url: String) {
super.onPageFinished(view, url) super.onPageFinished(view, url)
XLog.nst().d(url) XLog.tag("LoginController").d(url)
val parsedUrl = Uri.parse(url) val parsedUrl = Uri.parse(url)
if (parsedUrl.host.equals("forums.e-hentai.org", ignoreCase = true)) { if (parsedUrl.host.equals("forums.e-hentai.org", ignoreCase = true)) {
// Hide distracting content // Hide distracting content

View File

@ -27,7 +27,7 @@ class MetadataViewPresenter(
override fun onCreate(savedState: Bundle?) { override fun onCreate(savedState: Bundle?) {
super.onCreate(savedState) super.onCreate(savedState)
getMangaMetaObservable().subscribeLatestCache({ view, flatMetadata -> if (flatMetadata != null) view.onNextMetaInfo(flatMetadata) else XLog.nst().d("Invalid metadata") }) getMangaMetaObservable().subscribeLatestCache({ view, flatMetadata -> if (flatMetadata != null) view.onNextMetaInfo(flatMetadata) else XLog.tag("MetadataViewPresenter").disableStackTrace().d("Invalid metadata") })
getMangaObservable() getMangaObservable()
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())

View File

@ -21,7 +21,7 @@ fun Response.interceptAsHtml(block: (Document) -> Unit): Response {
block(parsed) block(parsed)
} catch (t: Throwable) { } catch (t: Throwable) {
// Ignore all errors // Ignore all errors
XLog.w("Interception error!", t) XLog.tag("Response.interceptAsHtml").enableStackTrace(2).w("Interception error!", t)
} finally { } finally {
close() close()
} }