mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-19 02:56:45 -06:00
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 com.huawei.agconnect.crash.AGConnectCrash
|
||||
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) {
|
||||
|
||||
@ -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() }
|
||||
|
||||
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?) {
|
||||
if (skipLog(priority, tag, message, t)) return
|
||||
|
||||
|
@ -7,7 +7,13 @@ import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.Fragment
|
||||
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 java.io.InterruptedIOException
|
||||
import java.net.SocketTimeoutException
|
||||
import java.net.UnknownHostException
|
||||
import javax.inject.Inject
|
||||
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 {
|
||||
|
||||
@ -52,9 +71,15 @@ class ActivityLifecycleLogger : Application.ActivityLifecycleCallbacks {
|
||||
}
|
||||
|
||||
@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()}")
|
||||
}
|
||||
|
||||
@ -62,7 +87,11 @@ class FragmentLifecycleLogger @Inject constructor() : FragmentManager.FragmentLi
|
||||
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()}")
|
||||
}
|
||||
|
||||
@ -78,7 +107,11 @@ class FragmentLifecycleLogger @Inject constructor() : FragmentManager.FragmentLi
|
||||
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")
|
||||
}
|
||||
|
||||
@ -90,7 +123,11 @@ class FragmentLifecycleLogger @Inject constructor() : FragmentManager.FragmentLi
|
||||
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()}")
|
||||
}
|
||||
|
||||
@ -102,3 +139,7 @@ class FragmentLifecycleLogger @Inject constructor() : FragmentManager.FragmentLi
|
||||
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 fr.bipi.tressence.base.FormatterPriorityTree
|
||||
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.scrapper.exception.FeatureDisabledException
|
||||
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() }
|
||||
|
||||
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?) {
|
||||
if (skipLog(priority, tag, message, t)) return
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user