Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Logging updates

Rich Turnerd404783570ca
diff --git a/client/src/main/java/org/openremote/app/client/notifications/NotificationsActivity.java b/client/src/main/java/org/openremote/app/client/notifications/NotificationsActivity.java
index d57a091c7..46a99146c 100644
--- a/client/src/main/java/org/openremote/app/client/notifications/NotificationsActivity.java
+++ b/client/src/main/java/org/openremote/app/client/notifications/NotificationsActivity.java
@@ -414,10 +414,8 @@ public class NotificationsActivity extends AssetBrowsingActivity<NotificationsPl
protected void refreshNotifications(Consumer<SentNotification[]> notificationConsumer) {
- SentNotification[] notifications = new SentNotification[0];
-
if (!canLoadNotifications()) {
- notificationConsumer.accept(notifications);
+ notificationConsumer.accept(new SentNotification[0]);
return;
}
@@ -437,7 +435,12 @@ public class NotificationsActivity extends AssetBrowsingActivity<NotificationsPl
userId,
assetId),
200,
- notificationConsumer::accept);
+ notifications ->
+ notificationConsumer.accept(
+ Arrays.stream(notifications)
+ .sorted(Comparator.comparingLong((SentNotification n) -> n.getSentOn().getTime()).reversed())
+ .toArray(SentNotification[]::new))
+ );
}
protected Notification buildNotification() {
diff --git a/manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.java b/manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.java
index b5649ece2..5b4fe1ac9 100644
--- a/manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.java
+++ b/manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.java
@@ -380,6 +380,8 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResour
new AttributeRef(assetId, attributeName), value, timerService.getCurrentTimeMillis()
);
+ LOG.info("Write attribute value request: " + event);
+
// Process asynchronously but block for a little while waiting for the result
Map<String, Object> headers = new HashMap<>();
headers.put(AttributeEvent.HEADER_SOURCE, CLIENT);
diff --git a/manager/src/main/java/org/openremote/manager/notification/NotificationService.java b/manager/src/main/java/org/openremote/manager/notification/NotificationService.java
index e2d6f2ab7..5fd0cf28e 100644
--- a/manager/src/main/java/org/openremote/manager/notification/NotificationService.java
+++ b/manager/src/main/java/org/openremote/manager/notification/NotificationService.java
@@ -201,7 +201,7 @@ public class NotificationService extends RouteBuilder implements ContainerServic
break;
}
- LOG.info("Sending notification from '" + source + ":" + sourceId.get() + "': " + notification);
+ LOG.info("Sending " + notification.getMessage().getType() + " notification '" + notification.getName() + "': '" + source + ":" + sourceId.get() + "' -> " + notification.getTargets());
// Check access permissions
checkAccess(notification.getTargets(), realmId, userId, isSuperUser, isRestrictedUser, assetId);
@@ -211,7 +211,7 @@ public class NotificationService extends RouteBuilder implements ContainerServic
.map(targetId -> {
Notification.Targets mappedTargets = handler.mapTarget(notification.getTargets().getType(), targetId, notification.getMessage());
if (mappedTargets == null || mappedTargets.getIds() == null || mappedTargets.getIds().length == 0) {
- LOG.finest("Failed to map target using '" + handler.getClass().getSimpleName() + "' handler: "
+ LOG.fine("Failed to map target using '" + handler.getClass().getSimpleName() + "' handler: "
+ notification.getTargets().getType() + ":" + targetId);
}
return mappedTargets;
@@ -270,15 +270,15 @@ public class NotificationService extends RouteBuilder implements ContainerServic
notification.getMessage());
if (result.isSuccess()) {
- LOG.fine("Notification sent: " + targets.getType() + ":" + targetId);
+ LOG.info("Notification sent '" + id + "': " + targets.getType() + ":" + targetId);
} else {
- LOG.warning("Notification failed: " + targets.getType() + ":" + targetId + ", reason=" + result.getMessage());
+ LOG.warning("Notification failed '" + id + "': " + targets.getType() + ":" + targetId + ", reason=" + result.getMessage());
sentNotification.setError(TextUtil.isNullOrEmpty(result.getMessage()) ? "Unknown error" : result.getMessage());
em.merge(sentNotification);
}
} catch (Exception e) {
LOG.log(Level.SEVERE,
- "Notification handler threw and exception whilst sending notification",
+ "Notification handler threw an exception whilst sending notification '" + id + "'",
e);
sentNotification.setError(TextUtil.isNullOrEmpty(e.getMessage()) ? "Unknown error" : e.getMessage());
em.merge(sentNotification);
diff --git a/manager/src/main/java/org/openremote/manager/notification/PushNotificationHandler.java b/manager/src/main/java/org/openremote/manager/notification/PushNotificationHandler.java
index 710efd2f2..5b1167cb6 100644
--- a/manager/src/main/java/org/openremote/manager/notification/PushNotificationHandler.java
+++ b/manager/src/main/java/org/openremote/manager/notification/PushNotificationHandler.java
@@ -273,7 +273,6 @@ public class PushNotificationHandler extends RouteBuilder implements Notificatio
@Override
public NotificationSendResult sendMessage(long id, Notification.TargetType targetType, String targetId, AbstractNotificationMessage message) {
- LOG.info("Sending notification '" + id + "' to: " + targetId);
if (targetType != Notification.TargetType.ASSET) {
LOG.warning("Target type not supported: " + targetType);
diff --git a/manager/src/main/java/org/openremote/manager/rules/geofence/ORConsoleGeofenceAssetAdapter.java b/manager/src/main/java/org/openremote/manager/rules/geofence/ORConsoleGeofenceAssetAdapter.java
index c0b4a161a..e3792845a 100644
--- a/manager/src/main/java/org/openremote/manager/rules/geofence/ORConsoleGeofenceAssetAdapter.java
+++ b/manager/src/main/java/org/openremote/manager/rules/geofence/ORConsoleGeofenceAssetAdapter.java
@@ -217,8 +217,6 @@ public class ORConsoleGeofenceAssetAdapter extends RouteBuilder implements Geofe
public GeofenceDefinition[] getAssetGeofences(String assetId) {
String realm = consoleIdRealmMap.get(assetId);
- LOG.info("Request for console geofences: " + assetId);
-
if (realm == null) {
LOG.info("Console ID not found in map so cannot retrieve geofences");
// Asset not supported by this adapter
@@ -229,7 +227,7 @@ public class ORConsoleGeofenceAssetAdapter extends RouteBuilder implements Geofe
if (assetStateLocationPredicates == null) {
// No geofences exist for this asset
- LOG.info("No geofences exist");
+ LOG.info("Request for console '" + assetId + "' geofences: 0 found");
return new GeofenceDefinition[0];
}
@@ -239,7 +237,7 @@ public class ORConsoleGeofenceAssetAdapter extends RouteBuilder implements Geofe
locationPredicate))
.toArray(GeofenceDefinition[]::new);
- LOG.info("Retrieved " + geofences.length + " geofence(s)");
+ LOG.info("Request for console '" + assetId + "' geofences: " + geofences.length + " found");
return geofences;
}