Adding severity when reporting an error

Severity is part of the PEL User Header section, and is used
to specify the PEL severity. This commit adds an option to pass
severity parameter while logging PEL. This will help to classify PELs
based on their severity. The commit also maintains uniformity in
the PEL Error logged.

Tested: By creating the error logs(pel) in error scenarios.

Signed-off-by: Pavithra Barithaya <pavithra.b@ibm.com>
Change-Id: Ic084d49b8ffe9aaea2c36c9fefa95a10a9c1c3ec
diff --git a/common/utils.cpp b/common/utils.cpp
index 076cd5c..7e43b49 100644
--- a/common/utils.cpp
+++ b/common/utils.cpp
@@ -448,7 +448,7 @@
     return response;
 }
 
-void reportError(const char* errorMsg)
+void reportError(const char* errorMsg, const Severity& sev)
 {
     auto& bus = pldm::utils::DBusHandler::getBus();
 
@@ -457,15 +457,19 @@
         using LoggingCreate =
             sdbusplus::client::xyz::openbmc_project::logging::Create<>;
 
+        std::string severity = "xyz.openbmc_project.Logging.Entry.Level.Error";
+
         using namespace sdbusplus::xyz::openbmc_project::Logging::server;
-        auto severity =
-            sdbusplus::xyz::openbmc_project::Logging::server::convertForMessage(
-                sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level::
-                    Error);
         auto method = bus.new_method_call(LoggingCreate::default_service,
                                           LoggingCreate::instance_path,
                                           LoggingCreate::interface, "Create");
 
+        auto itr = sevMap.find(sev);
+        if (itr != sevMap.end())
+        {
+            severity = itr->second;
+        }
+
         std::map<std::string, std::string> addlData{};
         method.append(errorMsg, severity, addlData);
         bus.call_noreply(method, dbusTimeout);