Log with Timber.

This commit is contained in:
Benoit Marty 2022-12-09 15:43:32 +01:00
parent 4136ba94e5
commit 9bf7c1ccf8
3 changed files with 6 additions and 6 deletions

View file

@ -1,10 +1,10 @@
package io.element.android.x.core.compose
import android.util.Log
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.remember
import io.element.android.x.core.BuildConfig
import timber.log.Timber
// Note the inline function below which ensures that this function is essentially
// copied at the call site to ensure that its logging only recompositions from the
@ -14,7 +14,7 @@ fun LogCompositions(tag: String, msg: String) {
if (BuildConfig.DEBUG) {
val ref = remember { Ref(0) }
SideEffect { ref.value++ }
Log.d(tag, "Compositions: $msg ${ref.value}")
Timber.d(tag, "Compositions: $msg ${ref.value}")
}
}

View file

@ -1,13 +1,13 @@
package io.element.android.x.core.data
import android.util.Log
import timber.log.Timber
inline fun <A> tryOrNull(message: String? = null, operation: () -> A): A? {
return try {
operation()
} catch (any: Throwable) {
if (message != null) {
Log.e("TAG", message, any)
Timber.e("TAG", message, any)
}
null
}

View file

@ -1,6 +1,5 @@
package io.element.android.x.designsystem.components.avatar
import android.util.Log
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
@ -18,6 +17,7 @@ import androidx.compose.ui.unit.sp
import coil.compose.AsyncImage
import io.element.android.x.designsystem.AvatarGradientEnd
import io.element.android.x.designsystem.AvatarGradientStart
import timber.log.Timber
@Composable
fun Avatar(avatarData: AvatarData, modifier: Modifier = Modifier) {
@ -45,7 +45,7 @@ private fun ImageAvatar(
AsyncImage(
model = avatarData.model,
onError = {
Log.e("TAG", "Error $it\n${it.result}", it.result.throwable)
Timber.e("TAG", "Error $it\n${it.result}", it.result.throwable)
},
contentDescription = null,
contentScale = ContentScale.Crop,