events: add severity to class generation

Use the severity field to add to the class generation for use
by phosphor-logging to commit entries.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I82bb8482c0f95435275fb3a1fcdcb37bd29fc7ec
diff --git a/include/sdbusplus/exception.hpp b/include/sdbusplus/exception.hpp
index 347418e..80f0d22 100644
--- a/include/sdbusplus/exception.hpp
+++ b/include/sdbusplus/exception.hpp
@@ -51,6 +51,7 @@
 struct generated_event_base : public generated_exception
 {
     virtual auto to_json() const -> nlohmann::json = 0;
+    virtual int severity() const noexcept = 0;
 };
 
 /** base exception for all new errors and events created by the sdbus++
@@ -78,6 +79,11 @@
         return Event::errErrno;
     }
 
+    int severity() const noexcept override
+    {
+        return Event::errSeverity;
+    }
+
     template <utility::details::consteval_string_holder V>
     using metadata_t = utility::consteval_string<V>;
 
diff --git a/tools/sdbusplus/templates/event.hpp.mako b/tools/sdbusplus/templates/event.hpp.mako
index c74efc9..1ae8d9d 100644
--- a/tools/sdbusplus/templates/event.hpp.mako
+++ b/tools/sdbusplus/templates/event.hpp.mako
@@ -26,6 +26,7 @@
         "${event.description}";
     static constexpr auto errWhat =
         "${events.name}.${event.name}: ${event.description}";
+    static constexpr int errSeverity = ${event.severity};
 
     static constexpr auto errErrno = ${event.errno};
 };
diff --git a/tools/sdbusplus/templates/events.hpp.mako b/tools/sdbusplus/templates/events.hpp.mako
index 4ea5297..97f10c9 100644
--- a/tools/sdbusplus/templates/events.hpp.mako
+++ b/tools/sdbusplus/templates/events.hpp.mako
@@ -5,6 +5,7 @@
 #include <sdbusplus/exception.hpp>
 
 #include <cerrno>
+#include <sys/syslog.h>
 
 % for h in events.cpp_includes():
 #include <${h}>