Created
May 7, 2025 14:44
-
-
Save Lutzifer/14363e65ff923024e417b27a9d7f671c to your computer and use it in GitHub Desktop.
RxKotlin Debug extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.reactivex.rxjava3.core.Observable | |
import timber.log.Timber | |
fun <T : Any> Observable<T>.debug(customTag: String? = null): Observable<T> { | |
val fileTag = Exception().stackTrace[0].fileName | |
val tag = if (customTag == null) fileTag else "$fileTag - $customTag" | |
val line = Exception().stackTrace[0].lineNumber | |
return this | |
.doOnNext { item -> | |
Timber.tag(tag).d("[LINE $line] Next item: $item") | |
}.doOnComplete { | |
Timber.tag(tag).d("[LINE $line] Completed") | |
}.doOnError { error -> | |
Timber.tag(tag).d("[LINE $line] Error: $error") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment