This is an automated email from the ASF dual-hosted git repository. jsinovassinnaik pushed a commit to branch UNOMI-621-add-logs in repository https://gitbox.apache.org/repos/asf/unomi.git
commit 510966796b1f500cdc2d66f282ffa9ec566bb673 Author: jsinovassin <jsinovassinn...@jahia.com> AuthorDate: Mon Aug 1 11:18:40 2022 +0200 UNOMI-621 : add error logs when events are invalid --- .../apache/unomi/rest/deserializers/ContextRequestDeserializer.java | 6 ++++++ .../rest/deserializers/EventsCollectorRequestDeserializer.java | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/rest/src/main/java/org/apache/unomi/rest/deserializers/ContextRequestDeserializer.java b/rest/src/main/java/org/apache/unomi/rest/deserializers/ContextRequestDeserializer.java index c14ec89ef..261a0fa73 100644 --- a/rest/src/main/java/org/apache/unomi/rest/deserializers/ContextRequestDeserializer.java +++ b/rest/src/main/java/org/apache/unomi/rest/deserializers/ContextRequestDeserializer.java @@ -29,6 +29,8 @@ import org.apache.unomi.api.Profile; import org.apache.unomi.api.services.PersonalizationService; import org.apache.unomi.rest.exception.InvalidRequestException; import org.apache.unomi.schema.api.SchemaService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.ArrayList; @@ -40,6 +42,8 @@ import java.util.Map; */ public class ContextRequestDeserializer extends StdDeserializer<ContextRequest> { + private static final Logger logger = LoggerFactory.getLogger(ContextRequestDeserializer.class); + private final SchemaService schemaService; public ContextRequestDeserializer(SchemaService schemaRegistry) { @@ -88,6 +92,8 @@ public class ContextRequestDeserializer extends StdDeserializer<ContextRequest> for (JsonNode event : events) { if (schemaService.isEventValid(event.toString(), event.get("eventType").textValue())) { filteredEvents.add(jsonParser.getCodec().treeToValue(event, Event.class)); + } else { + logger.error("An event was rejected - switch to DEBUG log level for more information"); } } cr.setEvents(filteredEvents); diff --git a/rest/src/main/java/org/apache/unomi/rest/deserializers/EventsCollectorRequestDeserializer.java b/rest/src/main/java/org/apache/unomi/rest/deserializers/EventsCollectorRequestDeserializer.java index 1bb272a0e..2114205ca 100644 --- a/rest/src/main/java/org/apache/unomi/rest/deserializers/EventsCollectorRequestDeserializer.java +++ b/rest/src/main/java/org/apache/unomi/rest/deserializers/EventsCollectorRequestDeserializer.java @@ -26,6 +26,8 @@ import org.apache.unomi.api.Event; import org.apache.unomi.api.EventsCollectorRequest; import org.apache.unomi.rest.exception.InvalidRequestException; import org.apache.unomi.schema.api.SchemaService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.ArrayList; @@ -36,6 +38,8 @@ import java.util.List; */ public class EventsCollectorRequestDeserializer extends StdDeserializer<EventsCollectorRequest> { + private static final Logger logger = LoggerFactory.getLogger(EventsCollectorRequestDeserializer.class); + private final SchemaService schemaService; public EventsCollectorRequestDeserializer(SchemaService schemaRegistry) { @@ -61,6 +65,8 @@ public class EventsCollectorRequestDeserializer extends StdDeserializer<EventsCo for (JsonNode event : eventsNode) { if (schemaService.isEventValid(event.toString(), event.get("eventType").textValue())) { filteredEvents.add(jsonParser.getCodec().treeToValue(event, Event.class)); + } else { + logger.error("An event was rejected - switch to DEBUG log level for more information"); } } }