Entry: Populate properties

Create an Entry dbus object when Commit is called and fill in
its properties with the journal data.

Change-Id: I155cacbdfdccfa8b1f594503d858710fa71f2026
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/log_manager.cpp b/log_manager.cpp
index c9edd7e..e9f11ec 100644
--- a/log_manager.cpp
+++ b/log_manager.cpp
@@ -7,6 +7,8 @@
 #include <systemd/sd-bus.h>
 #include <systemd/sd-journal.h>
 #include "elog-lookup.cpp"
+#include "config.h"
+#include "elog_entry.hpp"
 #include "log.hpp"
 #include "log_manager.hpp"
 
@@ -21,7 +23,6 @@
     constexpr const auto path = "/tmp/elog";
     constexpr const auto transactionIdVar = "TRANSACTION_ID";
 
-    // Create log file
     std::string filename{};
     filename.append(path);
     // TODO Create error logs in their own separate dir once permanent location
@@ -41,6 +42,7 @@
 
     std::string transactionIdStr = std::to_string(transactionId);
     std::vector<std::string> metalist = g_errMetaMap[errMsg];
+    std::vector<std::string> additionalData;
 
     // Read the journal from the end to get the most recent entry first.
     // The result from the sd_journal_get_data() is of the form VARIABLE=value.
@@ -78,6 +80,7 @@
         {
             continue;
         }
+
         efile << "\t\"@" << data << "\"," << std::endl;
 
         // Search for the metadata variables in the current journal entry
@@ -94,6 +97,7 @@
             }
 
             // Metatdata variable found, write to file
+            additionalData.push_back(std::string(data));
             efile << "\t\"@" << data << "\"," << std::endl;
         }
         efile << "\t}" << std::endl;
@@ -104,6 +108,18 @@
     }
     sd_journal_close(j);
 
+    // Create error Entry dbus object
+    entryId++;
+    auto objPath =  std::string(OBJ_ENTRY) + '/' +
+        std::to_string(entryId);
+    entries.insert(std::make_pair(entryId, std::make_unique<Entry>(
+            busLog,
+            objPath,
+            entryId,
+            (Entry::Level)g_errLevelMap[errMsg],
+            std::move(errMsg),
+            std::move(additionalData))));
+
     efile << "}" << std::endl;
     efile.close();
     return;