PEL: Let SRC class create a debug section

Add functionality so that when the SRC PEL section is being created, it
can save debug data (a vector of strings) along the way, and the PEL
class will then add that data into a JSON UserData section with any
other debug data.  The PEL class will then also write the debug data to
the journal.

This will be used for things like failure messages when looking up
callouts, additional information for device callouts, etc.

The functionality to save debug data is in the Section base class, so in
the future other Section classes can also save debug data for display in
the PEL.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I2f7923303e953c100c94ac81ba7c85152080fb72
diff --git a/extensions/openpower-pels/src.cpp b/extensions/openpower-pels/src.cpp
index 13a3ae5..d2e58d5 100644
--- a/extensions/openpower-pels/src.cpp
+++ b/extensions/openpower-pels/src.cpp
@@ -28,6 +28,7 @@
 namespace pv = openpower::pels::pel_values;
 namespace rg = openpower::pels::message;
 using namespace phosphor::logging;
+using namespace std::string_literals;
 
 constexpr size_t ccinSize = 4;
 
@@ -144,9 +145,9 @@
         // Can only set words 6 - 9
         if (!isUserDefinedWord(wordNum))
         {
-            log<level::WARNING>("SRC user data word out of range",
-                                entry("WORD_NUM=%d", wordNum),
-                                entry("ERROR_NAME=%s", regEntry.name.c_str()));
+            std::string msg =
+                "SRC user data word out of range: " + std::to_string(wordNum);
+            addDebugData(msg);
             continue;
         }
 
@@ -158,9 +159,9 @@
         }
         else
         {
-            log<level::WARNING>("Source for user data SRC word not found",
-                                entry("ADDITIONALDATA_KEY=%s", adName.c_str()),
-                                entry("ERROR_NAME=%s", regEntry.name.c_str()));
+            std::string msg =
+                "Source for user data SRC word not found: " + adName;
+            addDebugData(msg);
         }
     }
 }
@@ -542,8 +543,9 @@
         }
         catch (const SdBusError& e)
         {
-            std::string msg = "No VPD found for " + inventoryPath;
-            log<level::WARNING>(msg.c_str(), entry("ERROR=%s", e.what()));
+            std::string msg =
+                "No VPD found for " + inventoryPath + ": " + e.what();
+            addDebugData(msg);
 
             // Just create the callout with empty FRU fields
             callout = std::make_unique<src::Callout>(CalloutPriority::high,
@@ -552,8 +554,9 @@
     }
     catch (const SdBusError& e)
     {
-        std::string msg = "Could not get location code for " + inventoryPath;
-        log<level::WARNING>(msg.c_str(), entry("ERROR=%s", e.what()));
+        std::string msg = "Could not get location code for " + inventoryPath +
+                          ": " + e.what();
+        addDebugData(msg);
 
         // If this were to happen, people would have to look in the UserData
         // section that contains CALLOUT_INVENTORY_PATH to see what failed.
@@ -583,8 +586,9 @@
     }
     catch (std::exception& e)
     {
-        log<level::ERR>("Error parsing PEL message registry callout JSON",
-                        entry("ERROR=%s", e.what()));
+        std::string msg =
+            "Error parsing PEL message registry callout JSON: "s + e.what();
+        addDebugData(msg);
     }
 }