PEL: Define JSON schema to capture the journal

This chain of commits is adding the functionality to be able to capture
portions of the journal into PEL UserData sections by defining it in the
message registry entry for an error.

This commit updates the JSON schema for it, and the README.

From the README, examples are:

"JournalCapture": {
    "NumLines": 30
}

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

The first example will capture the previous 30 lines from the journal
into a single UserData section.

The second example 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.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I005a84547b43887a5f746832c68f4b40b6334404
diff --git a/extensions/openpower-pels/registry/README.md b/extensions/openpower-pels/registry/README.md
index 69ff800..d637b75 100644
--- a/extensions/openpower-pels/registry/README.md
+++ b/extensions/openpower-pels/registry/README.md
@@ -474,6 +474,48 @@
 }
 ```
 
+### Capturing the Journal
+
+The PEL daemon can be told to capture pieces of the journal in PEL UserData
+sections. This could be useful for debugging problems where a BMC dump which
+would also contain the journal isn't available.
+
+The 'JournalCapture' field has two formats, one that will create one UserData
+section with the previous N lines of the journal, and another that can capture
+any number of journal snippets based on the journal's SYSLOG_IDENTIFIER field.
+
+```json
+"JournalCapture": {
+    "NumLines": 30
+}
+```
+
+```json
+"JournalCapture":
+{
+    "Sections": [
+        {
+            "SyslogID": "phosphor-bmc-state-manager",
+            "NumLines": 20
+        },
+        {
+            "SyslogID": "phosphor-log-manager",
+            "NumLines": 15
+        }
+    ]
+}
+```
+
+The first example will capture the previous 30 lines from the journal into a
+single UserData section.
+
+The second example 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 UserData section would make the PEL exceed its maximum size of 16KB, it
+will be dropped.
+
 ## Modifying and Testing
 
 The general process for adding new entries to the message registry is:
diff --git a/extensions/openpower-pels/registry/schema/schema.json b/extensions/openpower-pels/registry/schema/schema.json
index 2c1602f..50066ee 100644
--- a/extensions/openpower-pels/registry/schema/schema.json
+++ b/extensions/openpower-pels/registry/schema/schema.json
@@ -55,7 +55,9 @@
                         "$ref": "#/definitions/calloutsUsingAD"
                     },
 
-                    "Callouts": { "$ref": "#/definitions/callouts" }
+                    "Callouts": { "$ref": "#/definitions/callouts" },
+
+                    "JournalCapture": { "$ref": "#/definitions/journalCapture" }
                 },
 
                 "required": ["Name", "SRC", "Documentation"],
@@ -755,6 +757,88 @@
         "calloutsWhenNoADMatch": {
             "description": "This contains the callouts to use when a match in the 'CalloutsWithTheirADValues array isn't found.",
             "$ref": "#/definitions/callouts"
+        },
+
+        "numLines": {
+            "description": "The number of lines of the journal to capture.",
+            "type": "integer",
+            "minimum": 1,
+            "maximum": 100
+        },
+
+        "syslogID": {
+            "description": "SYSLOG_IDENTIFIER value from the journal whose entries to capture.",
+            "type": "string",
+            "minLength": 1
+        },
+
+        "journalSection": {
+            "type": "object",
+            "properties": {
+                "SyslogID": { "$ref": "#/definitions/syslogID" },
+                "NumLines": { "$ref": "#/definitions/numLines" }
+            },
+            "additionalProperties": false,
+            "required": ["SyslogID", "NumLines"]
+        },
+
+        "journalSectionList": {
+            "description": "Describes which syslog IDs and how many journal lines to capture",
+            "type": "array",
+            "items": {
+                "$ref": "#/definitions/journalSection"
+            },
+            "minItems": 1,
+            "uniqueItems": true,
+            "examples": [
+                {
+                    "Sections": [
+                        {
+                            "SyslogID": "phosphor-bmc-state-manager",
+                            "NumLines": 20
+                        }
+                    ]
+                }
+            ]
+        },
+
+        "journalCapture": {
+            "description": "Allows a PEL to capture journal data in UserData sections.",
+            "type": "object",
+            "properties": {
+                "NumLines": { "$ref": "#/definitions/numLines" },
+                "Sections": { "$ref": "#/definitions/journalSectionList" }
+            },
+            "oneOf": [
+                {
+                    "required": ["NumLines"]
+                },
+                {
+                    "required": ["Sections"]
+                }
+            ],
+            "additionalProperties": false,
+            "examples": [
+                {
+                    "JournalCapture": {
+                        "NumLines": 30
+                    }
+                },
+                {
+                    "JournalCapture": {
+                        "Sections": [
+                            {
+                                "SyslogID": "phosphor-bmc-state-manager",
+                                "NumLines": 20
+                            },
+                            {
+                                "SyslogID": "phosphor-log-manager",
+                                "NumLines": 15
+                            }
+                        ]
+                    }
+                }
+            ]
         }
     }
 }