@@ -20,6 +20,7 @@ import io.element.android.libraries.androidutils.throttler.FirstThrottler
2020import io.element.android.libraries.core.cache.CircularCache
2121import io.element.android.libraries.core.coroutine.CoroutineDispatchers
2222import io.element.android.libraries.core.data.tryOrNull
23+ import io.element.android.libraries.core.log.logger.LoggerTag
2324import io.element.android.libraries.core.meta.BuildMeta
2425import io.element.android.libraries.di.AppScope
2526import io.element.android.libraries.di.SingleIn
@@ -30,6 +31,7 @@ import io.element.android.libraries.matrix.api.core.SessionId
3031import io.element.android.libraries.matrix.api.core.ThreadId
3132import io.element.android.libraries.matrix.api.user.MatrixUser
3233import io.element.android.libraries.push.api.notifications.NotificationDrawerManager
34+ import io.element.android.libraries.push.impl.log.notificationLoggerTag
3335import io.element.android.libraries.push.impl.notifications.model.NotifiableEvent
3436import io.element.android.services.appnavstate.api.AppNavigationStateService
3537import io.element.android.services.appnavstate.api.NavigationState
@@ -41,6 +43,8 @@ import kotlinx.coroutines.withContext
4143import timber.log.Timber
4244import javax.inject.Inject
4345
46+ private val loggerTag = LoggerTag (" DefaultNotificationDrawerManager" , notificationLoggerTag)
47+
4448/* *
4549 * The NotificationDrawerManager receives notification events as they arrived (from event stream or fcm) and
4650 * organise them in order to display them in the notification drawer.
@@ -116,13 +120,13 @@ class DefaultNotificationDrawerManager @Inject constructor(
116120
117121 private fun NotificationEventQueue.onNotifiableEventReceived (notifiableEvent : NotifiableEvent ) {
118122 if (buildMeta.lowPrivacyLoggingEnabled) {
119- Timber .d(" onNotifiableEventReceived(): $notifiableEvent " )
123+ Timber .tag(loggerTag.value). d(" onNotifiableEventReceived(): $notifiableEvent " )
120124 } else {
121- Timber .d(" onNotifiableEventReceived(): is push: ${notifiableEvent.canBeReplaced} " )
125+ Timber .tag(loggerTag.value). d(" onNotifiableEventReceived(): is push: ${notifiableEvent.canBeReplaced} " )
122126 }
123127
124128 if (filteredEventDetector.shouldBeIgnored(notifiableEvent)) {
125- Timber .d(" onNotifiableEventReceived(): ignore the event" )
129+ Timber .tag(loggerTag.value). d(" onNotifiableEventReceived(): ignore the event" )
126130 return
127131 }
128132
@@ -233,28 +237,28 @@ class DefaultNotificationDrawerManager @Inject constructor(
233237 private fun CoroutineScope.refreshNotificationDrawer (doRender : Boolean ) = launch {
234238 // Implement last throttler
235239 val canHandle = firstThrottler.canHandle()
236- Timber .v(" refreshNotificationDrawer($doRender ), delay: ${canHandle.waitMillis()} ms" )
240+ Timber .tag(loggerTag.value). v(" refreshNotificationDrawer($doRender ), delay: ${canHandle.waitMillis()} ms" )
237241 withContext(dispatchers.io) {
238242 delay(canHandle.waitMillis())
239243 try {
240244 refreshNotificationDrawerBg(doRender)
241245 } catch (throwable: Throwable ) {
242246 // It can happen if for instance session has been destroyed. It's a bit ugly to try catch like this, but it's safer
243- Timber .w(throwable, " refreshNotificationDrawerBg failure" )
247+ Timber .tag(loggerTag.value). w(throwable, " refreshNotificationDrawerBg failure" )
244248 }
245249 }
246250 }
247251
248252 private suspend fun refreshNotificationDrawerBg (doRender : Boolean ) {
249- Timber .v(" refreshNotificationDrawerBg($doRender )" )
253+ Timber .tag(loggerTag.value). v(" refreshNotificationDrawerBg($doRender )" )
250254 val eventsToRender = notificationState.updateQueuedEvents { queuedEvents, renderedEvents ->
251255 notifiableEventProcessor.process(queuedEvents.rawEvents(), renderedEvents).also {
252256 queuedEvents.clearAndAdd(it.onlyKeptEvents())
253257 }
254258 }
255259
256260 if (notificationState.hasAlreadyRendered(eventsToRender)) {
257- Timber .d(" Skipping notification update due to event list not changing" )
261+ Timber .tag(loggerTag.value). d(" Skipping notification update due to event list not changing" )
258262 } else {
259263 notificationState.clearAndAddRenderedEvents(eventsToRender)
260264 if (doRender) {
@@ -278,7 +282,7 @@ class DefaultNotificationDrawerManager @Inject constructor(
278282
279283 eventsForSessions.forEach { (sessionId, notifiableEvents) ->
280284 val currentUser = tryOrNull(
281- onError = { Timber .e(it, " Unable to retrieve info for user ${sessionId.value} " ) },
285+ onError = { Timber .tag(loggerTag.value). e(it, " Unable to retrieve info for user ${sessionId.value} " ) },
282286 operation = {
283287 val client = matrixClientProvider.getOrRestore(sessionId).getOrThrow()
284288 // myUserDisplayName cannot be empty else NotificationCompat.MessagingStyle() will crash
0 commit comments