PEL: Capture the journal in UserData sections

If a PEL message registry entry has a 'JournalCapture' section, capture
the listed portions of the journal in UserData sections for that error.

If the JSON looks like:

"JournalCapture": {
    "NumLines": 30
}

Then the code will capture the previous 30 lines from the journal into a
single UserData section.

If the JSON looks like:

"JournalCapture":
{
    "Sections": [
        {
            "SyslogID": "phosphor-bmc-state-manager",
            "NumLines": 20
        },
        {
            "SyslogID": "phosphor-log-manager",
            "NumLines": 15
        }
    ]
}

Then the code will create two UserData sections, the first with the most
recent 20 lines from phosphor-bmc-state-manager, and the second with 15
lines from phosphor-log-manager.

If a section would cause the PEL to exceed its maximum size of 16KB, it
will be dropped.  While the UserData class does have a shrink() method,
it prunes data from the end, which would cause the most recent journal
entries to be removed, which could be misleading.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I2ecbd8002b0e7087eb166a1219c6ab9da14a122a
diff --git a/extensions/openpower-pels/journal.hpp b/extensions/openpower-pels/journal.hpp
index 1261e32..620ce50 100644
--- a/extensions/openpower-pels/journal.hpp
+++ b/extensions/openpower-pels/journal.hpp
@@ -32,6 +32,11 @@
      */
     virtual std::vector<std::string> getMessages(const std::string& syslogID,
                                                  size_t maxMessages) const = 0;
+
+    /**
+     * @brief Call journalctl --sync to write unwritten journal data to disk
+     */
+    virtual void sync() const = 0;
 };
 
 /**
@@ -60,6 +65,11 @@
     std::vector<std::string> getMessages(const std::string& syslogID,
                                          size_t maxMessages) const override;
 
+    /**
+     * @brief Call journalctl --sync to write unwritten journal data to disk
+     */
+    void sync() const override;
+
   private:
     /**
      * @brief Gets a field from the current journal entry