forked from github/wulkanowy-mirror
Fix treessence upgrade (#1361)
This commit is contained in:
parent
18e0a59e2b
commit
f02db914bf
@ -3,11 +3,6 @@ package io.github.wulkanowy.utils
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.huawei.agconnect.crash.AGConnectCrash
|
import com.huawei.agconnect.crash.AGConnectCrash
|
||||||
import fr.bipi.tressence.base.FormatterPriorityTree
|
import fr.bipi.tressence.base.FormatterPriorityTree
|
||||||
import io.github.wulkanowy.sdk.exception.FeatureNotAvailableException
|
|
||||||
import io.github.wulkanowy.sdk.scrapper.exception.FeatureDisabledException
|
|
||||||
import java.io.InterruptedIOException
|
|
||||||
import java.net.SocketTimeoutException
|
|
||||||
import java.net.UnknownHostException
|
|
||||||
|
|
||||||
class CrashLogTree : FormatterPriorityTree(Log.VERBOSE) {
|
class CrashLogTree : FormatterPriorityTree(Log.VERBOSE) {
|
||||||
|
|
||||||
@ -20,21 +15,10 @@ class CrashLogTree : FormatterPriorityTree(Log.VERBOSE) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CrashLogExceptionTree : FormatterPriorityTree(Log.ERROR) {
|
class CrashLogExceptionTree : FormatterPriorityTree(Log.ERROR, ExceptionFilter) {
|
||||||
|
|
||||||
private val connectCrash by lazy { AGConnectCrash.getInstance() }
|
private val connectCrash by lazy { AGConnectCrash.getInstance() }
|
||||||
|
|
||||||
override fun skipLog(priority: Int, tag: String?, message: String, t: Throwable?): Boolean {
|
|
||||||
return when (t) {
|
|
||||||
is FeatureDisabledException,
|
|
||||||
is FeatureNotAvailableException,
|
|
||||||
is UnknownHostException,
|
|
||||||
is SocketTimeoutException,
|
|
||||||
is InterruptedIOException -> true
|
|
||||||
else -> super.skipLog(priority, tag, message, t)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
|
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
|
||||||
if (skipLog(priority, tag, message, t)) return
|
if (skipLog(priority, tag, message, t)) return
|
||||||
|
|
||||||
|
@ -7,7 +7,13 @@ import android.os.Bundle
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
|
import fr.bipi.tressence.common.filters.Filter
|
||||||
|
import io.github.wulkanowy.sdk.exception.FeatureNotAvailableException
|
||||||
|
import io.github.wulkanowy.sdk.scrapper.exception.FeatureDisabledException
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
import java.io.InterruptedIOException
|
||||||
|
import java.net.SocketTimeoutException
|
||||||
|
import java.net.UnknownHostException
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@ -18,7 +24,20 @@ class DebugLogTree : Timber.DebugTree() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Bundle?.checkSavedState() = if (this == null) "(STATE IS NULL)" else "(STATE IS NOT NULL)"
|
object ExceptionFilter : Filter {
|
||||||
|
|
||||||
|
override fun isLoggable(priority: Int, tag: String?) = true
|
||||||
|
|
||||||
|
override fun skipLog(priority: Int, tag: String?, message: String, t: Throwable?) =
|
||||||
|
when (t) {
|
||||||
|
is FeatureDisabledException,
|
||||||
|
is FeatureNotAvailableException,
|
||||||
|
is UnknownHostException,
|
||||||
|
is SocketTimeoutException,
|
||||||
|
is InterruptedIOException -> true
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class ActivityLifecycleLogger : Application.ActivityLifecycleCallbacks {
|
class ActivityLifecycleLogger : Application.ActivityLifecycleCallbacks {
|
||||||
|
|
||||||
@ -52,9 +71,15 @@ class ActivityLifecycleLogger : Application.ActivityLifecycleCallbacks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class FragmentLifecycleLogger @Inject constructor() : FragmentManager.FragmentLifecycleCallbacks() {
|
class FragmentLifecycleLogger @Inject constructor() :
|
||||||
|
FragmentManager.FragmentLifecycleCallbacks() {
|
||||||
|
|
||||||
override fun onFragmentViewCreated(fm: FragmentManager, f: Fragment, v: View, savedInstanceState: Bundle?) {
|
override fun onFragmentViewCreated(
|
||||||
|
fm: FragmentManager,
|
||||||
|
f: Fragment,
|
||||||
|
v: View,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
) {
|
||||||
Timber.d("${f::class.java.simpleName} VIEW CREATED ${savedInstanceState.checkSavedState()}")
|
Timber.d("${f::class.java.simpleName} VIEW CREATED ${savedInstanceState.checkSavedState()}")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +87,11 @@ class FragmentLifecycleLogger @Inject constructor() : FragmentManager.FragmentLi
|
|||||||
Timber.d("${f::class.java.simpleName} STOPPED")
|
Timber.d("${f::class.java.simpleName} STOPPED")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFragmentCreated(fm: FragmentManager, f: Fragment, savedInstanceState: Bundle?) {
|
override fun onFragmentCreated(
|
||||||
|
fm: FragmentManager,
|
||||||
|
f: Fragment,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
) {
|
||||||
Timber.d("${f::class.java.simpleName} CREATED ${savedInstanceState.checkSavedState()}")
|
Timber.d("${f::class.java.simpleName} CREATED ${savedInstanceState.checkSavedState()}")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +107,11 @@ class FragmentLifecycleLogger @Inject constructor() : FragmentManager.FragmentLi
|
|||||||
Timber.d("${f::class.java.simpleName} DESTROYED")
|
Timber.d("${f::class.java.simpleName} DESTROYED")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFragmentSaveInstanceState(fm: FragmentManager, f: Fragment, outState: Bundle) {
|
override fun onFragmentSaveInstanceState(
|
||||||
|
fm: FragmentManager,
|
||||||
|
f: Fragment,
|
||||||
|
outState: Bundle
|
||||||
|
) {
|
||||||
Timber.d("${f::class.java.simpleName} SAVED INSTANCE STATE")
|
Timber.d("${f::class.java.simpleName} SAVED INSTANCE STATE")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +123,11 @@ class FragmentLifecycleLogger @Inject constructor() : FragmentManager.FragmentLi
|
|||||||
Timber.d("${f::class.java.simpleName} VIEW DESTROYED")
|
Timber.d("${f::class.java.simpleName} VIEW DESTROYED")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFragmentActivityCreated(fm: FragmentManager, f: Fragment, savedInstanceState: Bundle?) {
|
override fun onFragmentActivityCreated(
|
||||||
|
fm: FragmentManager,
|
||||||
|
f: Fragment,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
) {
|
||||||
Timber.d("${f::class.java.simpleName} ACTIVITY CREATED ${savedInstanceState.checkSavedState()}")
|
Timber.d("${f::class.java.simpleName} ACTIVITY CREATED ${savedInstanceState.checkSavedState()}")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,3 +139,7 @@ class FragmentLifecycleLogger @Inject constructor() : FragmentManager.FragmentLi
|
|||||||
Timber.d("${f::class.java.simpleName} DETACHED")
|
Timber.d("${f::class.java.simpleName} DETACHED")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun Bundle?.checkSavedState() =
|
||||||
|
if (this == null) "(STATE IS NULL)" else "(STATE IS NOT NULL)"
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import android.util.Log
|
|||||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||||
import fr.bipi.tressence.base.FormatterPriorityTree
|
import fr.bipi.tressence.base.FormatterPriorityTree
|
||||||
import fr.bipi.tressence.common.StackTraceRecorder
|
import fr.bipi.tressence.common.StackTraceRecorder
|
||||||
|
import fr.bipi.tressence.common.filters.Filter
|
||||||
import io.github.wulkanowy.sdk.exception.FeatureNotAvailableException
|
import io.github.wulkanowy.sdk.exception.FeatureNotAvailableException
|
||||||
import io.github.wulkanowy.sdk.scrapper.exception.FeatureDisabledException
|
import io.github.wulkanowy.sdk.scrapper.exception.FeatureDisabledException
|
||||||
import java.io.InterruptedIOException
|
import java.io.InterruptedIOException
|
||||||
@ -21,18 +22,10 @@ class CrashLogTree : FormatterPriorityTree(Log.VERBOSE) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CrashLogExceptionTree : FormatterPriorityTree(Log.ERROR) {
|
class CrashLogExceptionTree : FormatterPriorityTree(Log.ERROR, ExceptionFilter) {
|
||||||
|
|
||||||
private val crashlytics by lazy { FirebaseCrashlytics.getInstance() }
|
private val crashlytics by lazy { FirebaseCrashlytics.getInstance() }
|
||||||
|
|
||||||
override fun skipLog(priority: Int, tag: String?, message: String, t: Throwable?): Boolean {
|
|
||||||
if (t is FeatureDisabledException || t is FeatureNotAvailableException || t is UnknownHostException || t is SocketTimeoutException || t is InterruptedIOException) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.skipLog(priority, tag, message, t)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
|
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
|
||||||
if (skipLog(priority, tag, message, t)) return
|
if (skipLog(priority, tag, message, t)) return
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user