PEL: Update D-Bus event sev based on PEL severity

Put in checks to ensure the D-Bus event log severity agrees with the
final PEL severity for PELs created by the BMC.  The D-bus property is
what is used in the Redfish event log, and we want to avoid cases like
having a Critical event log for an informational PEL.

This could happen in the case where the PEL message registry entry for
the event has a hardcoded or manufacturing specific severity value that
is different than the severity the D-Bus event log is first created
with.

This commit ensures that:
* If the PEL is nonError/recovered, the D-Bus severity is one of the
  non error ones.
* If the PEL isn't nonError/recovered, then the D-Bus severity also
  isn't.
* If the PEL is critical, the D-Bus severity is also critical.

It doesn't try to update the D-Bus severity for every PEL severity
because there isn't a one to one mapping - e.g. Notice, Debug, and
Informational D-Bus severities all map to a PEL severity of
nonError(informational).

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I6b0006034090e6d8e33e9f8b136ae50cce489f6e
diff --git a/extensions/openpower-pels/severity.hpp b/extensions/openpower-pels/severity.hpp
index f2b9921..a1c1a59 100644
--- a/extensions/openpower-pels/severity.hpp
+++ b/extensions/openpower-pels/severity.hpp
@@ -1,6 +1,9 @@
 #pragma once
 
 #include "elog_entry.hpp"
+#include "pel_types.hpp"
+
+#include <optional>
 
 namespace openpower
 {
@@ -16,5 +19,25 @@
  */
 uint8_t convertOBMCSeverityToPEL(phosphor::logging::Entry::Level severity);
 
+/**
+ * @brief Possibly calculate a new LogSeverity value based on the
+ *        current LogSeverity and PEL severity.
+ *
+ * Just handles cases where the LogSeverity value is clearly out of
+ * sync with the PEL severity:
+ * - critical PEL but non critical LogSeverity
+ * - info PEL but non info LogSeverity
+ * - non info PEL but info LogSeverity
+ *
+ * @param[in] obmcSeverity - The current LogSeverity
+ * @param[in] pelSeverity - The PEL severity
+ *
+ * @return optional<LogSeverity> The new LogSeverity to use if one was
+ *         found, otherwise std::nullopt which means the original one
+ *         is good enough.
+ */
+std::optional<phosphor::logging::Entry::Level>
+    fixupLogSeverity(phosphor::logging::Entry::Level obmcSeverity,
+                     SeverityType pelSeverity);
 } // namespace pels
 } // namespace openpower