diff --git a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/NotificationPollingService.kt b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/NotificationPollingService.kt index 357cf7e8d99..e813d439318 100644 --- a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/NotificationPollingService.kt +++ b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/NotificationPollingService.kt @@ -17,6 +17,7 @@ import software.aws.toolkits.core.utils.RemoteResolveParser import software.aws.toolkits.core.utils.RemoteResource import software.aws.toolkits.core.utils.error import software.aws.toolkits.core.utils.getLogger +import software.aws.toolkits.core.utils.info import software.aws.toolkits.core.utils.warn import software.aws.toolkits.jetbrains.core.DefaultRemoteResourceResolverProvider import software.aws.toolkits.jetbrains.core.RemoteResourceResolverProvider @@ -77,13 +78,16 @@ internal final class NotificationPollingService : Disposable { var lastException: Exception? = null while (retryCount < MAX_RETRIES) { + LOG.info { "Polling for notifications" } try { val newETag = getNotificationETag() if (newETag == NotificationEtagState.getInstance().etag) { // for when we need to notify on first poll even when there's no new ETag if (isFirstPoll.compareAndSet(true, false)) { - notifyObservers() + LOG.info { "No new notifications, checking cached notifications on first poll" } + return true } + LOG.info { "No new notifications to fetch" } return false } resourceResolver.get() @@ -91,6 +95,7 @@ internal final class NotificationPollingService : Disposable { .toCompletableFuture() .get() NotificationEtagState.getInstance().etag = newETag + LOG.info { "New notifications fetched" } return true } catch (e: Exception) { lastException = e diff --git a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/ProcessNotificationsBase.kt b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/ProcessNotificationsBase.kt index 5bbf34bba00..e759d9d079f 100644 --- a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/ProcessNotificationsBase.kt +++ b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/ProcessNotificationsBase.kt @@ -13,6 +13,8 @@ import com.intellij.openapi.application.PathManager import com.intellij.openapi.components.Service import com.intellij.openapi.components.service import com.intellij.openapi.project.Project +import software.aws.toolkits.core.utils.getLogger +import software.aws.toolkits.core.utils.info import software.aws.toolkits.core.utils.inputStream import software.aws.toolkits.jetbrains.utils.notifyStickyWithData import java.nio.file.Paths @@ -45,6 +47,7 @@ class ProcessNotificationsBase( fun retrieveStartupAndEmergencyNotifications() { val isStartupPoll = isStartup.compareAndSet(true, false) + LOG.info { "Retrieving notifications for processing. StartUp notifications included: $isStartupPoll" } val notifications = getNotificationsFromFile() notifications?.let { notificationsList -> val activeNotifications = notificationsList.notifications @@ -61,11 +64,13 @@ class ProcessNotificationsBase( activeNotifications.forEach { processNotification(project, it) } } + LOG.info { "Finished processing notifications" } } fun processNotification(project: Project, notificationData: NotificationData) { val shouldShow = RulesEngine.displayNotification(project, notificationData) if (shouldShow) { + LOG.info { "Showing notification with id: ${notificationData.id}" } val notificationContent = notificationData.content.locale val severity = notificationData.severity val followupActions = NotificationManager.createActions( @@ -105,6 +110,7 @@ class ProcessNotificationsBase( notifListener.add(newNotifListener) companion object { + private val LOG = getLogger() fun getInstance(project: Project): ProcessNotificationsBase = project.service() private const val NOTIFICATIONS_PATH = "aws-static-resources/notifications.json"