entry: use map for metadata in ctor

Transition the entry constructor to use the `map<string,string>`
rather than the `vector<string>`.

Tested: UTs pass and daemon still creates logs.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Icf3ead163cc99a1498734d33335fb6da52e6c98c
diff --git a/elog_entry.hpp b/elog_entry.hpp
index 4290a50..ccb69a3 100644
--- a/elog_entry.hpp
+++ b/elog_entry.hpp
@@ -65,7 +65,7 @@
      */
     Entry(sdbusplus::bus_t& bus, const std::string& objectPath, uint32_t idErr,
           uint64_t timestampErr, Level severityErr, std::string&& msgErr,
-          std::vector<std::string>&& additionalDataErr,
+          std::map<std::string, std::string>&& additionalDataErr,
           AssociationList&& objects, const std::string& fwVersion,
           const std::string& filePath, internal::Manager& parent) :
         EntryIfaces(bus, objectPath.c_str(), EntryIfaces::action::defer_emit),
@@ -76,8 +76,8 @@
         timestamp(timestampErr, true);
         updateTimestamp(timestampErr, true);
         message(std::move(msgErr), true);
-        additionalData(std::move(additionalDataErr), true);
-        additionalData2(util::additional_data::parse(additionalData()), true);
+        additionalData2(std::move(additionalDataErr), true);
+        additionalData(util::additional_data::combine(additionalData2()), true);
         associations(std::move(objects), true);
         // Store a copy of associations in case we need to recreate
         assocs = associations();
diff --git a/lib/lg2_commit.cpp b/lib/lg2_commit.cpp
index 2f1caab..6916bf5 100644
--- a/lib/lg2_commit.cpp
+++ b/lib/lg2_commit.cpp
@@ -107,18 +107,9 @@
 }
 
 auto extractEvent(sdbusplus::exception::generated_event_base&& t)
-    -> std::tuple<std::string, Entry::Level, std::vector<std::string>>
+    -> std::tuple<std::string, Entry::Level, std::map<std::string, std::string>>
 {
-    auto data = data_from_json(t);
-    std::vector<std::string> additional_data = {};
-
-    for (auto& [key, data] : data)
-    {
-        additional_data.emplace_back(key + "=" + data);
-    }
-
-    return {t.name(), severity_from_syslog(t.severity()),
-            std::move(additional_data)};
+    return {t.name(), severity_from_syslog(t.severity()), data_from_json(t)};
 }
 
 } // namespace details
diff --git a/lib/lg2_commit.hpp b/lib/lg2_commit.hpp
index db6bab0..1ab4302 100644
--- a/lib/lg2_commit.hpp
+++ b/lib/lg2_commit.hpp
@@ -17,6 +17,7 @@
  *  @return A tuple containing the message, level, and additional data.
  */
 auto extractEvent(sdbusplus::exception::generated_event_base&&)
-    -> std::tuple<std::string, Entry::Level, std::vector<std::string>>;
+    -> std::tuple<std::string, Entry::Level,
+                  std::map<std::string, std::string>>;
 
 } // namespace lg2::details
diff --git a/log_manager.cpp b/log_manager.cpp
index 125677e..d5a2638 100644
--- a/log_manager.cpp
+++ b/log_manager.cpp
@@ -193,12 +193,12 @@
 
         sd_journal_close(j);
     }
-    createEntry(errMsg, errLvl, additionalData);
+    createEntry(errMsg, errLvl, util::additional_data::parse(additionalData));
 }
 
 auto Manager::createEntry(
     std::string errMsg, Entry::Level errLvl,
-    std::vector<std::string> additionalData,
+    std::map<std::string, std::string> additionalData,
     const FFDCEntries& ffdc) -> sdbusplus::message::object_path
 {
     if (!Extensions::disableDefaultLogCaps())
@@ -234,7 +234,8 @@
     auto objPath = std::string(OBJ_ENTRY) + '/' + std::to_string(entryId);
 
     AssociationList objects{};
-    processMetadata(errMsg, additionalData, objects);
+    auto additionalDataVec = util::additional_data::combine(additionalData);
+    processMetadata(errMsg, additionalDataVec, objects);
 
     auto e = std::make_unique<Entry>(
         busLog, objPath, entryId,
@@ -706,10 +707,7 @@
                      const std::map<std::string, std::string>& additionalData,
                      const FFDCEntries& ffdc) -> sdbusplus::message::object_path
 {
-    // Convert the map into a vector of "key=value" strings
-    auto ad = util::additional_data::combine(additionalData);
-
-    return createEntry(message, severity, ad, ffdc);
+    return createEntry(message, severity, additionalData, ffdc);
 }
 
 } // namespace internal
diff --git a/log_manager.hpp b/log_manager.hpp
index 2535832..c5b6eb0 100644
--- a/log_manager.hpp
+++ b/log_manager.hpp
@@ -270,7 +270,7 @@
      * vector.
      */
     auto createEntry(std::string errMsg, Entry::Level errLvl,
-                     std::vector<std::string> additionalData,
+                     std::map<std::string, std::string> additionalData,
                      const FFDCEntries& ffdc = FFDCEntries{})
         -> sdbusplus::message::object_path;
 
diff --git a/test/elog_quiesce_test.cpp b/test/elog_quiesce_test.cpp
index 7894f95..9c822df 100644
--- a/test/elog_quiesce_test.cpp
+++ b/test/elog_quiesce_test.cpp
@@ -41,7 +41,8 @@
     std::string message{"test error"};
     std::string fwLevel{"level42"};
     std::string path{"/tmp/99"};
-    std::vector<std::string> testData{"no", "callout"};
+    std::map<std::string, std::string> testData{{"no", "no"},
+                                                {"callout", "callout"}};
     phosphor::logging::AssociationList associations{};
 
     Entry elog{mockedBus,
@@ -67,9 +68,9 @@
     std::string message{"test error"};
     std::string fwLevel{"level42"};
     std::string path{"/tmp/99"};
-    std::vector<std::string> testData{
-        "CALLOUT_INVENTORY_PATH=/xyz/openbmc_project/inventory/system/chassis/"
-        "motherboard/powersupply0/"};
+    std::map<std::string, std::string> testData{
+        {"CALLOUT_INVENTORY_PATH",
+         "/xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply0/"}};
     phosphor::logging::AssociationList associations{};
 
     Entry elog{mockedBus,
@@ -95,9 +96,9 @@
     std::string message{"test error"};
     std::string fwLevel{"level42"};
     std::string path{"/tmp/99"};
-    std::vector<std::string> testData{
-        "CALLOUT_INVENTORY_PATH=/xyz/openbmc_project/inventory/system/chassis/"
-        "motherboard/powersupply0/"};
+    std::map<std::string, std::string> testData{
+        {"CALLOUT_INVENTORY_PATH",
+         "/xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply0/"}};
     phosphor::logging::AssociationList associations{};
 
     // Ensure D-Bus object created for this blocking error
@@ -152,9 +153,9 @@
     std::string message{"test error"};
     std::string fwLevel{"level42"};
     std::string path{"/tmp/99"};
-    std::vector<std::string> testData{
-        "CALLOUT_INVENTORY_PATH=/xyz/openbmc_project/inventory/system/chassis/"
-        "motherboard/powersupply0/"};
+    std::map<std::string, std::string> testData{
+        {"CALLOUT_INVENTORY_PATH",
+         "/xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply0/"}};
     phosphor::logging::AssociationList associations{};
 
     // Ensure D-Bus object created for this blocking error
@@ -211,9 +212,9 @@
     std::string message{"test error"};
     std::string fwLevel{"level42"};
     std::string path{"/tmp/99"};
-    std::vector<std::string> testData{
-        "CALLOUT_INVENTORY_PATH=/xyz/openbmc_project/inventory/system/chassis/"
-        "motherboard/powersupply0/"};
+    std::map<std::string, std::string> testData{
+        {"CALLOUT_INVENTORY_PATH",
+         "/xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply0/"}};
     phosphor::logging::AssociationList associations{};
 
     // Ensure D-Bus object created for this blocking error
diff --git a/test/elog_update_ts_test.cpp b/test/elog_update_ts_test.cpp
index cabcb60..fe1089f 100644
--- a/test/elog_update_ts_test.cpp
+++ b/test/elog_update_ts_test.cpp
@@ -61,7 +61,7 @@
     std::string message{"test error"};
     std::string fwLevel{"level42"};
     std::string path{"/tmp/99"};
-    std::vector<std::string> testData{"additional", "data"};
+    std::map<std::string, std::string> testData{{"additional", "data"}};
     phosphor::logging::AssociationList associations{};
 
     Entry elog{bus,
@@ -132,7 +132,7 @@
     std::string message{"test error"};
     std::string fwLevel{"level42"};
     std::string path{"/tmp/99"};
-    std::vector<std::string> testData{"additional", "data"};
+    std::map<std::string, std::string> testData{{"additional", "data"}};
     phosphor::logging::AssociationList associations{};
 
     Entry elog{bus,
diff --git a/test/serialization_test_properties.cpp b/test/serialization_test_properties.cpp
index 60fc6ae..f769c93 100644
--- a/test/serialization_test_properties.cpp
+++ b/test/serialization_test_properties.cpp
@@ -13,7 +13,8 @@
 {
     auto id = 99;
     phosphor::logging::AssociationList assocations{};
-    std::vector<std::string> testData{"additional=1", "data=yes"};
+    std::map<std::string, std::string> testData = {{"additional", "1"},
+                                                   {"data", "yes"}};
     uint64_t timestamp{100};
     std::string message{"test error"};
     std::string fwLevel{"level42"};