Skip to content

Commit 7d080ea

Browse files
committed
Add Timber tags.
1 parent 020839f commit 7d080ea

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/NotifiableEventProcessor.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
package io.element.android.libraries.push.impl.notifications
1818

19+
import io.element.android.libraries.core.log.logger.LoggerTag
1920
import io.element.android.libraries.matrix.api.timeline.item.event.EventType
21+
import io.element.android.libraries.push.impl.log.notificationLoggerTag
2022
import io.element.android.libraries.push.impl.notifications.model.FallbackNotifiableEvent
2123
import io.element.android.libraries.push.impl.notifications.model.InviteNotifiableEvent
2224
import io.element.android.libraries.push.impl.notifications.model.NotifiableEvent
@@ -29,6 +31,8 @@ import javax.inject.Inject
2931

3032
private typealias ProcessedEvents = List<ProcessedEvent<NotifiableEvent>>
3133

34+
private val loggerTag = LoggerTag("NotifiableEventProcessor", notificationLoggerTag)
35+
3236
class NotifiableEventProcessor @Inject constructor(
3337
private val outdatedDetector: OutdatedEventDetector,
3438
private val appNavigationStateService: AppNavigationStateService,
@@ -45,10 +49,10 @@ class NotifiableEventProcessor @Inject constructor(
4549
is NotifiableMessageEvent -> when {
4650
it.shouldIgnoreEventInRoom(appState) -> {
4751
ProcessedEvent.Type.REMOVE
48-
.also { Timber.d("notification message removed due to currently viewing the same room or thread") }
52+
.also { Timber.tag(loggerTag.value).d("notification message removed due to currently viewing the same room or thread") }
4953
}
5054
outdatedDetector.isMessageOutdated(it) -> ProcessedEvent.Type.REMOVE
51-
.also { Timber.d("notification message removed due to being read") }
55+
.also { Timber.tag(loggerTag.value).d("notification message removed due to being read") }
5256
else -> ProcessedEvent.Type.KEEP
5357
}
5458
is SimpleNotifiableEvent -> when (it.type) {
@@ -58,7 +62,7 @@ class NotifiableEventProcessor @Inject constructor(
5862
is FallbackNotifiableEvent -> when {
5963
it.shouldIgnoreEventInRoom(appState) -> {
6064
ProcessedEvent.Type.REMOVE
61-
.also { Timber.d("notification fallback removed due to currently viewing the same room or thread") }
65+
.also { Timber.tag(loggerTag.value).d("notification fallback removed due to currently viewing the same room or thread") }
6266
}
6367
else -> ProcessedEvent.Type.KEEP
6468
}

libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/NotifiableEventResolver.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import io.element.android.libraries.matrix.api.timeline.item.event.TextMessageTy
3636
import io.element.android.libraries.matrix.api.timeline.item.event.UnknownMessageType
3737
import io.element.android.libraries.matrix.api.timeline.item.event.VideoMessageType
3838
import io.element.android.libraries.push.impl.R
39-
import io.element.android.libraries.push.impl.log.pushLoggerTag
39+
import io.element.android.libraries.push.impl.log.notificationLoggerTag
4040
import io.element.android.libraries.push.impl.notifications.model.FallbackNotifiableEvent
4141
import io.element.android.libraries.push.impl.notifications.model.InviteNotifiableEvent
4242
import io.element.android.libraries.push.impl.notifications.model.NotifiableEvent
@@ -47,7 +47,7 @@ import io.element.android.services.toolbox.api.systemclock.SystemClock
4747
import timber.log.Timber
4848
import javax.inject.Inject
4949

50-
private val loggerTag = LoggerTag("NotifiableEventResolver", pushLoggerTag)
50+
private val loggerTag = LoggerTag("NotifiableEventResolver", notificationLoggerTag)
5151

5252
/**
5353
* The notifiable event resolver is able to create a NotifiableEvent (view model for notifications) from an sdk Event.

libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/NotificationRenderer.kt

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616

1717
package io.element.android.libraries.push.impl.notifications
1818

19+
import io.element.android.libraries.core.log.logger.LoggerTag
1920
import io.element.android.libraries.matrix.api.core.RoomId
2021
import io.element.android.libraries.matrix.api.user.MatrixUser
22+
import io.element.android.libraries.push.impl.log.notificationLoggerTag
2123
import io.element.android.libraries.push.impl.notifications.model.FallbackNotifiableEvent
2224
import io.element.android.libraries.push.impl.notifications.model.InviteNotifiableEvent
2325
import io.element.android.libraries.push.impl.notifications.model.NotifiableEvent
@@ -26,6 +28,8 @@ import io.element.android.libraries.push.impl.notifications.model.SimpleNotifiab
2628
import timber.log.Timber
2729
import javax.inject.Inject
2830

31+
private val loggerTag = LoggerTag("NotificationRenderer", notificationLoggerTag)
32+
2933
class NotificationRenderer @Inject constructor(
3034
private val notificationIdProvider: NotificationIdProvider,
3135
private val notificationDisplayer: NotificationDisplayer,
@@ -54,7 +58,7 @@ class NotificationRenderer @Inject constructor(
5458

5559
// Remove summary first to avoid briefly displaying it after dismissing the last notification
5660
if (summaryNotification == SummaryNotification.Removed) {
57-
Timber.d("Removing summary notification")
61+
Timber.tag(loggerTag.value).d("Removing summary notification")
5862
notificationDisplayer.cancelNotificationMessage(
5963
tag = null,
6064
id = notificationIdProvider.getSummaryNotificationId(currentUser.userId)
@@ -64,14 +68,14 @@ class NotificationRenderer @Inject constructor(
6468
roomNotifications.forEach { wrapper ->
6569
when (wrapper) {
6670
is RoomNotification.Removed -> {
67-
Timber.d("Removing room messages notification ${wrapper.roomId}")
71+
Timber.tag(loggerTag.value).d("Removing room messages notification ${wrapper.roomId}")
6872
notificationDisplayer.cancelNotificationMessage(
6973
tag = wrapper.roomId.value,
7074
id = notificationIdProvider.getRoomMessagesNotificationId(currentUser.userId)
7175
)
7276
}
7377
is RoomNotification.Message -> if (useCompleteNotificationFormat) {
74-
Timber.d("Updating room messages notification ${wrapper.meta.roomId}")
78+
Timber.tag(loggerTag.value).d("Updating room messages notification ${wrapper.meta.roomId}")
7579
notificationDisplayer.showNotificationMessage(
7680
tag = wrapper.meta.roomId.value,
7781
id = notificationIdProvider.getRoomMessagesNotificationId(currentUser.userId),
@@ -84,14 +88,14 @@ class NotificationRenderer @Inject constructor(
8488
invitationNotifications.forEach { wrapper ->
8589
when (wrapper) {
8690
is OneShotNotification.Removed -> {
87-
Timber.d("Removing invitation notification ${wrapper.key}")
91+
Timber.tag(loggerTag.value).d("Removing invitation notification ${wrapper.key}")
8892
notificationDisplayer.cancelNotificationMessage(
8993
tag = wrapper.key,
9094
id = notificationIdProvider.getRoomInvitationNotificationId(currentUser.userId)
9195
)
9296
}
9397
is OneShotNotification.Append -> if (useCompleteNotificationFormat) {
94-
Timber.d("Updating invitation notification ${wrapper.meta.key}")
98+
Timber.tag(loggerTag.value).d("Updating invitation notification ${wrapper.meta.key}")
9599
notificationDisplayer.showNotificationMessage(
96100
tag = wrapper.meta.key,
97101
id = notificationIdProvider.getRoomInvitationNotificationId(currentUser.userId),
@@ -104,14 +108,14 @@ class NotificationRenderer @Inject constructor(
104108
simpleNotifications.forEach { wrapper ->
105109
when (wrapper) {
106110
is OneShotNotification.Removed -> {
107-
Timber.d("Removing simple notification ${wrapper.key}")
111+
Timber.tag(loggerTag.value).d("Removing simple notification ${wrapper.key}")
108112
notificationDisplayer.cancelNotificationMessage(
109113
tag = wrapper.key,
110114
id = notificationIdProvider.getRoomEventNotificationId(currentUser.userId)
111115
)
112116
}
113117
is OneShotNotification.Append -> if (useCompleteNotificationFormat) {
114-
Timber.d("Updating simple notification ${wrapper.meta.key}")
118+
Timber.tag(loggerTag.value).d("Updating simple notification ${wrapper.meta.key}")
115119
notificationDisplayer.showNotificationMessage(
116120
tag = wrapper.meta.key,
117121
id = notificationIdProvider.getRoomEventNotificationId(currentUser.userId),
@@ -124,14 +128,14 @@ class NotificationRenderer @Inject constructor(
124128
fallbackNotifications.forEach { wrapper ->
125129
when (wrapper) {
126130
is OneShotNotification.Removed -> {
127-
Timber.d("Removing fallback notification ${wrapper.key}")
131+
Timber.tag(loggerTag.value).d("Removing fallback notification ${wrapper.key}")
128132
notificationDisplayer.cancelNotificationMessage(
129133
tag = wrapper.key,
130134
id = notificationIdProvider.getFallbackNotificationId(currentUser.userId)
131135
)
132136
}
133137
is OneShotNotification.Append -> if (useCompleteNotificationFormat) {
134-
Timber.d("Updating fallback notification ${wrapper.meta.key}")
138+
Timber.tag(loggerTag.value).d("Updating fallback notification ${wrapper.meta.key}")
135139
notificationDisplayer.showNotificationMessage(
136140
tag = wrapper.meta.key,
137141
id = notificationIdProvider.getFallbackNotificationId(currentUser.userId),
@@ -143,7 +147,7 @@ class NotificationRenderer @Inject constructor(
143147

144148
// Update summary last to avoid briefly displaying it before other notifications
145149
if (summaryNotification is SummaryNotification.Update) {
146-
Timber.d("Updating summary notification")
150+
Timber.tag(loggerTag.value).d("Updating summary notification")
147151
notificationDisplayer.showNotificationMessage(
148152
tag = null,
149153
id = notificationIdProvider.getSummaryNotificationId(currentUser.userId),

0 commit comments

Comments
 (0)