Log with Timber.
This commit is contained in:
parent
af8c5180ca
commit
061ac9bce3
3 changed files with 6 additions and 6 deletions
|
|
@ -1,10 +1,10 @@
|
||||||
package io.element.android.x.core.compose
|
package io.element.android.x.core.compose
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.SideEffect
|
import androidx.compose.runtime.SideEffect
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import io.element.android.x.core.BuildConfig
|
import io.element.android.x.core.BuildConfig
|
||||||
|
import timber.log.Timber
|
||||||
|
|
||||||
// Note the inline function below which ensures that this function is essentially
|
// 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
|
// 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) {
|
if (BuildConfig.DEBUG) {
|
||||||
val ref = remember { Ref(0) }
|
val ref = remember { Ref(0) }
|
||||||
SideEffect { ref.value++ }
|
SideEffect { ref.value++ }
|
||||||
Log.d(tag, "Compositions: $msg ${ref.value}")
|
Timber.d(tag, "Compositions: $msg ${ref.value}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package io.element.android.x.core.data
|
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? {
|
inline fun <A> tryOrNull(message: String? = null, operation: () -> A): A? {
|
||||||
return try {
|
return try {
|
||||||
operation()
|
operation()
|
||||||
} catch (any: Throwable) {
|
} catch (any: Throwable) {
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
Log.e("TAG", message, any)
|
Timber.e("TAG", message, any)
|
||||||
}
|
}
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package io.element.android.x.designsystem.components.avatar
|
package io.element.android.x.designsystem.components.avatar
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
|
|
@ -18,6 +17,7 @@ import androidx.compose.ui.unit.sp
|
||||||
import coil.compose.AsyncImage
|
import coil.compose.AsyncImage
|
||||||
import io.element.android.x.designsystem.AvatarGradientEnd
|
import io.element.android.x.designsystem.AvatarGradientEnd
|
||||||
import io.element.android.x.designsystem.AvatarGradientStart
|
import io.element.android.x.designsystem.AvatarGradientStart
|
||||||
|
import timber.log.Timber
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Avatar(avatarData: AvatarData, modifier: Modifier = Modifier) {
|
fun Avatar(avatarData: AvatarData, modifier: Modifier = Modifier) {
|
||||||
|
|
@ -45,7 +45,7 @@ private fun ImageAvatar(
|
||||||
AsyncImage(
|
AsyncImage(
|
||||||
model = avatarData.model,
|
model = avatarData.model,
|
||||||
onError = {
|
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,
|
contentDescription = null,
|
||||||
contentScale = ContentScale.Crop,
|
contentScale = ContentScale.Crop,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue