Improve logs.

This commit is contained in:
Benoit Marty 2023-04-04 11:57:39 +02:00 committed by Benoit Marty
parent 7e7e798acf
commit 25604b2651

View file

@ -16,12 +16,14 @@
package io.element.android.libraries.push.impl
import io.element.android.libraries.core.log.logger.LoggerTag
import io.element.android.libraries.matrix.api.MatrixClient
import io.element.android.libraries.matrix.api.auth.MatrixAuthenticationService
import io.element.android.libraries.matrix.api.core.SessionId
import io.element.android.libraries.matrix.api.pusher.SetHttpPusherData
import io.element.android.libraries.push.impl.clientsecret.PushClientSecret
import io.element.android.libraries.push.impl.config.PushConfig
import io.element.android.libraries.push.impl.log.pushLoggerTag
import io.element.android.libraries.push.impl.pushgateway.PushGatewayNotifyRequest
import io.element.android.libraries.push.impl.userpushstore.UserPushStoreFactory
import io.element.android.libraries.push.impl.userpushstore.isFirebase
@ -33,6 +35,8 @@ import javax.inject.Inject
internal const val DEFAULT_PUSHER_FILE_TAG = "mobile"
private val loggerTag = LoggerTag("PushersManager", pushLoggerTag)
// TODO EAx Communicate with the SDK
class PushersManager @Inject constructor(
private val unifiedPushHelper: UnifiedPushHelper,
@ -81,7 +85,7 @@ class PushersManager @Inject constructor(
registerPusher(client, firebaseToken, PushConfig.pusher_http_url)
}
} else {
Timber.d("This session is not using Firebase pusher")
Timber.tag(loggerTag.value).d("This session is not using Firebase pusher")
}
}
}
@ -92,7 +96,7 @@ class PushersManager @Inject constructor(
suspend fun registerPusher(matrixClient: MatrixClient, pushKey: String, gateway: String) {
val userDataStore = userPushStoreFactory.create(matrixClient.sessionId.value)
if (userDataStore.getCurrentRegisteredPushKey() == pushKey) {
Timber.d("Unnecessary to register again the same pusher")
Timber.tag(loggerTag.value).d("Unnecessary to register again the same pusher")
} else {
// Register the pusher to the server
matrixClient.pushersService().setHttpPusher(
@ -102,7 +106,7 @@ class PushersManager @Inject constructor(
userDataStore.setCurrentRegisteredPushKey(pushKey)
},
{ throwable ->
Timber.e(throwable, "Unable to register the pusher")
Timber.tag(loggerTag.value).e(throwable, "Unable to register the pusher")
}
)
}