1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2024-09-20 05:49:10 -05:00

Fix treessence upgrade (#1361)

This commit is contained in:
Rafał Borcz 2021-06-02 12:45:16 +02:00 committed by GitHub
parent 18e0a59e2b
commit f02db914bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 32 deletions

View File

@ -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

View File

@ -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)"

View File

@ -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