Skip to content

Commit e36aecf

Browse files
committed
add logs for polling and processing notifs
1 parent 1eefd62 commit e36aecf

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: 7 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
@@ -103,6 +108,7 @@ internal final class NotificationPollingService : Disposable {
103108
}
104109
}
105110
emitFailureMetric(lastException)
111+
LOG.error { "Failed to poll for notifications after $MAX_RETRIES attempts" }
106112
return false
107113
}
108114

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

Lines changed: 5 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
@@ -66,6 +69,7 @@ class ProcessNotificationsBase(
6669
fun processNotification(project: Project, notificationData: NotificationData) {
6770
val shouldShow = RulesEngine.displayNotification(project, notificationData)
6871
if (shouldShow) {
72+
LOG.info { "Showing notification with id: ${notificationData.id}" }
6973
val notificationContent = notificationData.content.locale
7074
val severity = notificationData.severity
7175
val followupActions = NotificationManager.createActions(
@@ -105,6 +109,7 @@ class ProcessNotificationsBase(
105109
notifListener.add(newNotifListener)
106110

107111
companion object {
112+
private val LOG = getLogger<ProcessNotificationsBase>()
108113
fun getInstance(project: Project): ProcessNotificationsBase = project.service()
109114

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

0 commit comments

Comments
 (0)