mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-14 21:18:56 +01:00
Add network inspection logging mode
This commit is contained in:
@@ -24,6 +24,7 @@ import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.data.updater.UpdaterJob
|
||||
import eu.kanade.tachiyomi.util.LocaleHelper
|
||||
import exh.log.CrashlyticsPrinter
|
||||
import exh.log.EHLogLevel
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmConfiguration
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
@@ -109,8 +110,7 @@ open class App : Application() {
|
||||
|
||||
// EXH
|
||||
private fun setupExhLogging() {
|
||||
val logLevel = if(BuildConfig.DEBUG ||
|
||||
Injekt.get<PreferencesHelper>().eh_detailedLogs().getOrDefault()) {
|
||||
val logLevel = if(BuildConfig.DEBUG || EHLogLevel.shouldLog(EHLogLevel.EXTRA)) {
|
||||
LogLevel.ALL
|
||||
} else {
|
||||
LogLevel.WARN
|
||||
|
||||
@@ -183,5 +183,5 @@ object PreferenceKeys {
|
||||
|
||||
const val eh_showTransitionPages = "eh_show_transition_pages"
|
||||
|
||||
const val eh_detailedLogs = "eh_detailed_logs"
|
||||
const val eh_logLevel = "eh_log_level"
|
||||
}
|
||||
|
||||
@@ -256,5 +256,5 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun eh_showTransitionPages() = rxPrefs.getBoolean(Keys.eh_showTransitionPages, true)
|
||||
|
||||
fun eh_detailedLogs() = rxPrefs.getBoolean(Keys.eh_detailedLogs, false)
|
||||
fun eh_logLevel() = rxPrefs.getInteger(Keys.eh_logLevel, 0)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.network
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import exh.log.maybeInjectEHLogger
|
||||
import okhttp3.*
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
@@ -25,6 +26,7 @@ class NetworkHelper(context: Context) {
|
||||
.cookieJar(cookieManager)
|
||||
.cache(Cache(cacheDir, cacheSize))
|
||||
.enableTLS12()
|
||||
.maybeInjectEHLogger()
|
||||
.build()
|
||||
|
||||
val cloudflareClient = client.newBuilder()
|
||||
|
||||
@@ -22,6 +22,7 @@ import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.ui.library.LibraryController
|
||||
import eu.kanade.tachiyomi.util.toast
|
||||
import exh.debug.SettingsDebugController
|
||||
import exh.log.EHLogLevel
|
||||
import exh.ui.migration.MetadataFetchDialog
|
||||
import rx.Observable
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
@@ -119,19 +120,17 @@ class SettingsAdvancedController : SettingsController() {
|
||||
summary = "Apply TachiyomiEH enhancements to the following sources if they are installed: ${DELEGATED_SOURCES.values.joinToString { it.sourceName }}"
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
title = "Detailed logs"
|
||||
intListPreference {
|
||||
key = PreferenceKeys.eh_logLevel
|
||||
title = "Log level"
|
||||
|
||||
if(BuildConfig.DEBUG) {
|
||||
summary = "Force-enabled in this debug build."
|
||||
isChecked = true
|
||||
isPersistent = false
|
||||
isEnabled = false
|
||||
} else {
|
||||
key = PreferenceKeys.eh_detailedLogs
|
||||
defaultValue = false
|
||||
summary = "Increase detail level of logs. May cause the app to become slightly slower."
|
||||
}
|
||||
entries = EHLogLevel.values().map {
|
||||
"${it.name.toLowerCase().capitalize()} (${it.description})"
|
||||
}.toTypedArray()
|
||||
entryValues = EHLogLevel.values().mapIndexed { index, _ -> "$index" }.toTypedArray()
|
||||
defaultValue = "0"
|
||||
|
||||
summary = "Changing this can impact app performance. Force-restart app after changing. Current value: %s"
|
||||
}
|
||||
|
||||
preference {
|
||||
|
||||
Reference in New Issue
Block a user