Un-break XLog network logging, code contributed from Neko
This commit is contained in:
parent
7ccaea0d72
commit
d3603a664c
@ -13,6 +13,7 @@ import eu.kanade.tachiyomi.source.model.MangasPage
|
|||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
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 exh.log.maybeInjectEHLogger
|
||||||
import exh.patch.injectPatches
|
import exh.patch.injectPatches
|
||||||
import exh.source.DelegatedHttpSource
|
import exh.source.DelegatedHttpSource
|
||||||
import okhttp3.Headers
|
import okhttp3.Headers
|
||||||
@ -42,12 +43,14 @@ abstract class HttpSource : CatalogueSource {
|
|||||||
get() = delegate?.networkHttpClient ?: original.client
|
get() = delegate?.networkHttpClient ?: original.client
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
.injectPatches { id }
|
.injectPatches { id }
|
||||||
|
.maybeInjectEHLogger()
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
override val cloudflareClient: OkHttpClient
|
override val cloudflareClient: OkHttpClient
|
||||||
get() = delegate?.networkCloudflareClient ?: original.cloudflareClient
|
get() = delegate?.networkCloudflareClient ?: original.cloudflareClient
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
.injectPatches { id }
|
.injectPatches { id }
|
||||||
|
.maybeInjectEHLogger()
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
override val cookieManager: AndroidCookieJar
|
override val cookieManager: AndroidCookieJar
|
||||||
|
@ -1,16 +1,23 @@
|
|||||||
package exh.log
|
package exh.log
|
||||||
|
|
||||||
|
import com.elvishew.xlog.XLog
|
||||||
|
import com.google.gson.Gson
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.logging.HttpLoggingInterceptor
|
||||||
|
|
||||||
fun OkHttpClient.Builder.maybeInjectEHLogger(): OkHttpClient.Builder { // TODO - un-break this
|
fun OkHttpClient.Builder.maybeInjectEHLogger(): OkHttpClient.Builder {
|
||||||
/* if(false &&EHLogLevel.shouldLog(EHLogLevel.EXTREME)) {
|
if (EHLogLevel.shouldLog(EHLogLevel.EXTREME)) {
|
||||||
val xLogger = XLog.tag("EHNetwork")
|
val logger: HttpLoggingInterceptor.Logger = object : HttpLoggingInterceptor.Logger {
|
||||||
.nst()
|
override fun log(message: String) {
|
||||||
val interceptor = HttpLoggingInterceptor {
|
try {
|
||||||
xLogger.d(it)
|
Gson().fromJson(message, Any::class.java)
|
||||||
|
XLog.tag("||EH-NETWORK-JSON").nst().json(message)
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
XLog.tag("||EH-NETWORK").nb().nst().d(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return addInterceptor(HttpLoggingInterceptor(logger).apply { level = HttpLoggingInterceptor.Level.BODY })
|
||||||
}
|
}
|
||||||
interceptor.level = HttpLoggingInterceptor.Level.BODY
|
|
||||||
return addInterceptor(interceptor)
|
|
||||||
} */
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user