Skip to content

Commit b2e012a

Browse files
Add logging info to IDE notification polling and processing (#5138)
* add logs for polling and processing notifs * redundant * finish log
1 parent 1eefd62 commit b2e012a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/NotificationPollingService.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import software.aws.toolkits.core.utils.RemoteResolveParser
1717
import software.aws.toolkits.core.utils.RemoteResource
1818
import software.aws.toolkits.core.utils.error
1919
import software.aws.toolkits.core.utils.getLogger
20+
import software.aws.toolkits.core.utils.info
2021
import software.aws.toolkits.core.utils.warn
2122
import software.aws.toolkits.jetbrains.core.DefaultRemoteResourceResolverProvider
2223
import software.aws.toolkits.jetbrains.core.RemoteResourceResolverProvider
@@ -77,20 +78,24 @@ internal final class NotificationPollingService : Disposable {
7778
var lastException: Exception? = null
7879

7980
while (retryCount < MAX_RETRIES) {
81+
LOG.info { "Polling for notifications" }
8082
try {
8183
val newETag = getNotificationETag()
8284
if (newETag == NotificationEtagState.getInstance().etag) {
8385
// for when we need to notify on first poll even when there's no new ETag
8486
if (isFirstPoll.compareAndSet(true, false)) {
85-
notifyObservers()
87+
LOG.info { "No new notifications, checking cached notifications on first poll" }
88+
return true
8689
}
90+
LOG.info { "No new notifications to fetch" }
8791
return false
8892
}
8993
resourceResolver.get()
9094
.resolve(notificationsResource)
9195
.toCompletableFuture()
9296
.get()
9397
NotificationEtagState.getInstance().etag = newETag
98+
LOG.info { "New notifications fetched" }
9499
return true
95100
} catch (e: Exception) {
96101
lastException = e

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/ProcessNotificationsBase.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import com.intellij.openapi.application.PathManager
1313
import com.intellij.openapi.components.Service
1414
import com.intellij.openapi.components.service
1515
import com.intellij.openapi.project.Project
16+
import software.aws.toolkits.core.utils.getLogger
17+
import software.aws.toolkits.core.utils.info
1618
import software.aws.toolkits.core.utils.inputStream
1719
import software.aws.toolkits.jetbrains.utils.notifyStickyWithData
1820
import java.nio.file.Paths
@@ -45,6 +47,7 @@ class ProcessNotificationsBase(
4547

4648
fun retrieveStartupAndEmergencyNotifications() {
4749
val isStartupPoll = isStartup.compareAndSet(true, false)
50+
LOG.info { "Retrieving notifications for processing. StartUp notifications included: $isStartupPoll" }
4851
val notifications = getNotificationsFromFile()
4952
notifications?.let { notificationsList ->
5053
val activeNotifications = notificationsList.notifications
@@ -61,11 +64,13 @@ class ProcessNotificationsBase(
6164

6265
activeNotifications.forEach { processNotification(project, it) }
6366
}
67+
LOG.info { "Finished processing notifications" }
6468
}
6569

6670
fun processNotification(project: Project, notificationData: NotificationData) {
6771
val shouldShow = RulesEngine.displayNotification(project, notificationData)
6872
if (shouldShow) {
73+
LOG.info { "Showing notification with id: ${notificationData.id}" }
6974
val notificationContent = notificationData.content.locale
7075
val severity = notificationData.severity
7176
val followupActions = NotificationManager.createActions(
@@ -105,6 +110,7 @@ class ProcessNotificationsBase(
105110
notifListener.add(newNotifListener)
106111

107112
companion object {
113+
private val LOG = getLogger<ProcessNotificationsBase>()
108114
fun getInstance(project: Project): ProcessNotificationsBase = project.service()
109115

110116
private const val NOTIFICATIONS_PATH = "aws-static-resources/notifications.json"

0 commit comments

Comments
 (0)