Add Timber tag.
This commit is contained in:
parent
122841a026
commit
cf2c8dfe3b
1 changed files with 11 additions and 8 deletions
|
|
@ -27,6 +27,7 @@ import im.vector.app.features.analytics.plan.UserProperties
|
||||||
import io.element.android.features.networkmonitor.api.NetworkMonitor
|
import io.element.android.features.networkmonitor.api.NetworkMonitor
|
||||||
import io.element.android.features.networkmonitor.api.NetworkStatus
|
import io.element.android.features.networkmonitor.api.NetworkStatus
|
||||||
import io.element.android.libraries.architecture.Presenter
|
import io.element.android.libraries.architecture.Presenter
|
||||||
|
import io.element.android.libraries.core.log.logger.LoggerTag
|
||||||
import io.element.android.libraries.matrix.api.MatrixClient
|
import io.element.android.libraries.matrix.api.MatrixClient
|
||||||
import io.element.android.libraries.matrix.api.encryption.EncryptionService
|
import io.element.android.libraries.matrix.api.encryption.EncryptionService
|
||||||
import io.element.android.libraries.matrix.api.encryption.RecoveryState
|
import io.element.android.libraries.matrix.api.encryption.RecoveryState
|
||||||
|
|
@ -39,6 +40,8 @@ import kotlinx.coroutines.flow.map
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
private val pusherTag = LoggerTag("Pusher", LoggerTag.PushLoggerTag)
|
||||||
|
|
||||||
class LoggedInPresenter @Inject constructor(
|
class LoggedInPresenter @Inject constructor(
|
||||||
private val matrixClient: MatrixClient,
|
private val matrixClient: MatrixClient,
|
||||||
private val networkMonitor: NetworkMonitor,
|
private val networkMonitor: NetworkMonitor,
|
||||||
|
|
@ -78,29 +81,29 @@ class LoggedInPresenter @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun ensurePusherIsRegistered() {
|
private suspend fun ensurePusherIsRegistered() {
|
||||||
Timber.d("Ensure pusher is registered")
|
Timber.tag(pusherTag.value).d("Ensure pusher is registered")
|
||||||
val currentPushProvider = pushService.getCurrentPushProvider()
|
val currentPushProvider = pushService.getCurrentPushProvider()
|
||||||
val result = if (currentPushProvider == null) {
|
val result = if (currentPushProvider == null) {
|
||||||
Timber.d("Register with the first available push provider")
|
Timber.tag(pusherTag.value).d("Register with the first available push provider")
|
||||||
val pushProvider = pushService.getAvailablePushProviders().firstOrNull()
|
val pushProvider = pushService.getAvailablePushProviders().firstOrNull()
|
||||||
?: return Unit.also { Timber.w("No push provider available") }
|
?: return Unit.also { Timber.tag(pusherTag.value).w("No push provider available") }
|
||||||
val distributor = pushProvider.getDistributors().firstOrNull()
|
val distributor = pushProvider.getDistributors().firstOrNull()
|
||||||
?: return Unit.also { Timber.w("No distributor available") }
|
?: return Unit.also { Timber.tag(pusherTag.value).w("No distributor available") }
|
||||||
pushService.registerWith(matrixClient, pushProvider, distributor)
|
pushService.registerWith(matrixClient, pushProvider, distributor)
|
||||||
} else {
|
} else {
|
||||||
val currentPushDistributor = currentPushProvider.getCurrentDistributor(matrixClient)
|
val currentPushDistributor = currentPushProvider.getCurrentDistributor(matrixClient)
|
||||||
if (currentPushDistributor == null) {
|
if (currentPushDistributor == null) {
|
||||||
Timber.d("Register with the first available distributor")
|
Timber.tag(pusherTag.value).d("Register with the first available distributor")
|
||||||
val distributor = currentPushProvider.getDistributors().firstOrNull()
|
val distributor = currentPushProvider.getDistributors().firstOrNull()
|
||||||
?: return Unit.also { Timber.w("No distributor available") }
|
?: return Unit.also { Timber.tag(pusherTag.value).w("No distributor available") }
|
||||||
pushService.registerWith(matrixClient, currentPushProvider, distributor)
|
pushService.registerWith(matrixClient, currentPushProvider, distributor)
|
||||||
} else {
|
} else {
|
||||||
Timber.d("Re-register with the current distributor")
|
Timber.tag(pusherTag.value).d("Re-register with the current distributor")
|
||||||
pushService.registerWith(matrixClient, currentPushProvider, currentPushDistributor)
|
pushService.registerWith(matrixClient, currentPushProvider, currentPushDistributor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.onFailure {
|
result.onFailure {
|
||||||
Timber.e(it, "Failed to register pusher")
|
Timber.tag(pusherTag.value).e(it, "Failed to register pusher")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue