PEL: Read the journal info from the registry

Add support to the Registry class to read the JournalCapture information
out of the registry entry for an error if it is there.  This will then
be used by the PEL class when creating a PEL.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I529e4fb352c6eb33ad73b2a04ac4467710865139
diff --git a/extensions/openpower-pels/registry.cpp b/extensions/openpower-pels/registry.cpp
index 87d9875..9cccb0b 100644
--- a/extensions/openpower-pels/registry.cpp
+++ b/extensions/openpower-pels/registry.cpp
@@ -578,6 +578,58 @@
     return getCalloutsWithoutAD((*it)["Callouts"], systemNames);
 }
 
+/**
+ * @brief Returns the journal capture information
+ *
+ *  The JSON looks like:
+ *    "JournalCapture": {
+ *        "NumLines": 30
+ *    }
+ *
+ *    "JournalCapture":
+ *    {
+ *        "Sections": [
+ *            {
+ *                "SyslogID": "phosphor-log-manager",
+ *                "NumLines": 20
+ *            }
+ *        ]
+ *    }
+ *
+ * @param json - The journal capture JSON
+ * @return JournalCapture - The filled in variant
+ */
+JournalCapture getJournalCapture(const nlohmann::json& json)
+{
+    JournalCapture capt;
+
+    // Primary key is either NumLines or Sections.
+    if (json.contains("NumLines"))
+    {
+        capt = json.at("NumLines").get<size_t>();
+    }
+    else if (json.contains("Sections"))
+    {
+        AppCaptureList captures;
+        for (const auto& capture : json.at("Sections"))
+        {
+            AppCapture ac;
+            ac.syslogID = capture.at("SyslogID").get<std::string>();
+            ac.numLines = capture.at("NumLines").get<size_t>();
+            captures.push_back(std::move(ac));
+        }
+
+        capt = captures;
+    }
+    else
+    {
+        log<level::ERR>("JournalCapture section not the right format");
+        throw std::runtime_error{"JournalCapture section not the right format"};
+    }
+
+    return capt;
+}
+
 } // namespace helper
 
 std::optional<Entry> Registry::lookup(const std::string& name, LookupType type,
@@ -704,6 +756,12 @@
                 }
             }
 
+            if (e->contains("JournalCapture"))
+            {
+                entry.journalCapture =
+                    helper::getJournalCapture((*e)["JournalCapture"]);
+            }
+
             return entry;
         }
         catch (const std::exception& ex)