Use an enum to return message registry parsing status

We need to handle an event differently if it's not found in the
registries vs. failing to parse, so a simple success/fail return status
is no longer enough.

This adds an enum to return additional status information so we can
continue parsing events if one is not found in a registry.

Tested:
Confirmed that events not found in the registry are still correctly
skipped.

Change-Id: Ib3be587fc165670e231a2897d490416bd29530be
Signed-off-by: Jason M. Bills <jason.m.bills@intel.com>
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 16df24c..b69a8a5 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -1048,23 +1048,31 @@
         });
 }
 
-static int fillEventLogEntryJson(const std::string& logEntryID,
-                                 const std::string& logEntry,
-                                 nlohmann::json::object_t& logEntryJson)
+enum class LogParseError
+{
+    success,
+    parseFailed,
+    messageIdNotInRegistry,
+};
+
+static LogParseError
+    fillEventLogEntryJson(const std::string& logEntryID,
+                          const std::string& logEntry,
+                          nlohmann::json::object_t& logEntryJson)
 {
     // The redfish log format is "<Timestamp> <MessageId>,<MessageArgs>"
     // First get the Timestamp
     size_t space = logEntry.find_first_of(' ');
     if (space == std::string::npos)
     {
-        return 1;
+        return LogParseError::parseFailed;
     }
     std::string timestamp = logEntry.substr(0, space);
     // Then get the log contents
     size_t entryStart = logEntry.find_first_not_of(' ', space);
     if (entryStart == std::string::npos)
     {
-        return 1;
+        return LogParseError::parseFailed;
     }
     std::string_view entry(logEntry);
     entry.remove_prefix(entryStart);
@@ -1075,7 +1083,7 @@
     // We need at least a MessageId to be valid
     if (logEntryFields.empty())
     {
-        return 1;
+        return LogParseError::parseFailed;
     }
     std::string& messageID = logEntryFields[0];
 
@@ -1085,7 +1093,7 @@
     if (message == nullptr)
     {
         BMCWEB_LOG_WARNING << "Log entry not found in registry: " << logEntry;
-        return 0;
+        return LogParseError::messageIdNotInRegistry;
     }
 
     std::string msg = message->message;
@@ -1139,7 +1147,7 @@
     logEntryJson["EntryType"] = "Event";
     logEntryJson["Severity"] = message->messageSeverity;
     logEntryJson["Created"] = std::move(timestamp);
-    return 0;
+    return LogParseError::success;
 }
 
 inline void requestRoutesJournalEventLogEntryCollection(App& app)
@@ -1202,17 +1210,18 @@
                 firstEntry = false;
 
                 nlohmann::json::object_t bmcLogEntry;
-                if (fillEventLogEntryJson(idStr, logEntry, bmcLogEntry) != 0)
+                LogParseError status =
+                    fillEventLogEntryJson(idStr, logEntry, bmcLogEntry);
+                if (status == LogParseError::messageIdNotInRegistry)
+                {
+                    continue;
+                }
+                if (status != LogParseError::success)
                 {
                     messages::internalError(asyncResp->res);
                     return;
                 }
 
-                if (bmcLogEntry.empty())
-                {
-                    continue;
-                }
-
                 entryCount++;
                 // Handle paging using skip (number of entries to skip from the
                 // start) and top (number of entries to display)
@@ -1281,8 +1290,9 @@
                 if (idStr == targetID)
                 {
                     nlohmann::json::object_t bmcLogEntry;
-                    if (fillEventLogEntryJson(idStr, logEntry, bmcLogEntry) !=
-                        0)
+                    LogParseError status =
+                        fillEventLogEntryJson(idStr, logEntry, bmcLogEntry);
+                    if (status != LogParseError::success)
                     {
                         messages::internalError(asyncResp->res);
                         return;