Skip to content
Snippets Groups Projects
Unverified Commit 19d35ac7 authored by Matthias Urhahn's avatar Matthias Urhahn Committed by GitHub
Browse files

Fix coroutine scope canceling log spam (DEV) (#2317)


* Clean up log spam for CancellationExceptions.

* Clean up log spam for CancellationExceptions.

* Adjust log level to `error` for flows that completed due to an exception being bubbled up.

Co-authored-by: default avatarharambasicluka <64483219+harambasicluka@users.noreply.github.com>
parent 3dfd4d8e
No related branches found
No related tags found
No related merge requests found
......@@ -90,7 +90,10 @@ class BackgroundModeStatus @Inject constructor(
.onStart { emit(pollisIgnoringBatteryOptimizations()) }
.distinctUntilChanged()
.onCompletion {
if (it != null) Timber.w(it, "isIgnoringBatteryOptimizations failed.")
when {
it is CancellationException -> Timber.d("isIgnoringBatteryOptimizations canceled.")
it != null -> Timber.e(it, "isIgnoringBatteryOptimizations failed.")
}
}
.shareLatest(
tag = "isIgnoringBatteryOptimizations",
......
package de.rki.coronawarnapp.util.flow
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.flow.Flow
......@@ -80,8 +81,11 @@ class HotDataFlow<T : Any>(
}
}
.onCompletion { err ->
if (err != null) Timber.tag(tag).w(err, "internal onCompletion due to error")
else Timber.tag(tag).v("internal onCompletion")
when {
err is CancellationException -> Timber.tag(tag).d("internal onCompletion due to cancelation")
err != null -> Timber.tag(tag).e(err, "internal onCompletion due to error")
else -> Timber.tag(tag).v("internal onCompletion")
}
}
.shareIn(
scope = scope + coroutineContext,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment