Add HostEvent support to Commit interface

Temporary support for the HostEvent data that is checked in
instead of auto-generated.

Change-Id: I34e0c8d91dd51b26efaadbe0cd8be951f0e4bc01
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/log_manager.cpp b/log_manager.cpp
index ef1cae8..e84f27e 100644
--- a/log_manager.cpp
+++ b/log_manager.cpp
@@ -8,6 +8,7 @@
 #include <systemd/sd-bus.h>
 #include <systemd/sd-journal.h>
 #include "elog-lookup.cpp"
+#include "elog-errors-HostEvent.hpp"
 #include "config.h"
 #include "elog_entry.hpp"
 #include "log.hpp"
@@ -43,6 +44,7 @@
 
     std::string transactionIdStr = std::to_string(transactionId);
     std::vector<std::string> metalist = g_errMetaMap[errMsg];
+    std::vector<std::string> metalistHostEvent = g_errMetaMapHostEvent[errMsg];
     std::vector<std::string> additionalData;
 
     // Read the journal from the end to get the most recent entry first.
@@ -103,6 +105,26 @@
         }
         efile << "\t}" << std::endl;
 
+        // TODO Remove once host event error header file is auto-generated.
+        // Tracking with issue openbmc/phosphor-logging#4
+        for (auto metaVarStrHostEvent : metalistHostEvent)
+        {
+            rc = sd_journal_get_data(j, metaVarStrHostEvent.c_str(),
+                                    (const void **)&data, &length);
+            if (rc < 0)
+            {
+                // Not found, continue to next metadata variable
+                logging::log<logging::level::INFO>("Failed to find metadata",
+                        logging::entry("META_FIELD=%s",
+                        metaVarStrHostEvent.c_str()));
+                continue;
+            }
+
+            // Metatdata variable found, write to file
+            additionalData.push_back(std::string(data));
+            efile << "\t\"@" << data << "\"," << std::endl;
+        }
+
         // TODO Break only once all metadata fields have been found. Implement
         // once this function reads the metadata fields from the header file.
         break;