PHAL: added createPEL wrapper function
Added wrapper function to create PEL based on event type.
Why: concurrent code update feature requires to create to
PEL, based on event types in various use cases. This will
help to reduce duplicate code.
Tested: verified PEL log
Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
Change-Id: I21d46775994f5c2f86124e33bf98dd9044f3e5d8
diff --git a/extensions/phal/create_pel.cpp b/extensions/phal/create_pel.cpp
index b6e9c74..6c53228 100644
--- a/extensions/phal/create_pel.cpp
+++ b/extensions/phal/create_pel.cpp
@@ -86,7 +86,7 @@
}
}
-void createHostRunningPEL()
+void createPEL(const std::string& event)
{
std::map<std::string, std::string> additionalData;
auto bus = sdbusplus::bus::new_default();
@@ -94,8 +94,6 @@
try
{
- static constexpr auto bootErrorMessage =
- "org.open_power.PHAL.Error.HostRunning";
std::string service =
util::getService(bus, loggingObjectPath, loggingInterface);
auto method = bus.new_method_call(service.c_str(), loggingObjectPath,
@@ -104,23 +102,26 @@
sdbusplus::xyz::openbmc_project::Logging::server::convertForMessage(
sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level::
Error);
- method.append(bootErrorMessage, level, additionalData);
+ method.append(event, level, additionalData);
auto resp = bus.call(method);
}
catch (const sdbusplus::exception::SdBusError& e)
{
- log<level::ERR>("sdbusplus D-Bus call exception",
- entry("OBJPATH=%s", loggingObjectPath),
- entry("INTERFACE=%s", loggingInterface),
- entry("EXCEPTION=%s", e.what()));
+ log<level::ERR>(fmt::format("sdbusplus D-Bus call exception",
+ "OBJPATH={}, INTERFACE={}, EXCEPTION={}",
+ loggingObjectPath, loggingInterface,
+ e.what())
+ .c_str());
+ ;
throw std::runtime_error(
"Error in invoking D-Bus logging create interface");
}
catch (std::exception& e)
{
- log<level::ERR>("D-bus call exception",
- entry("EXCEPTION=%s", e.what()));
+ log<level::ERR>(
+ fmt::format("D-bus call exception", "EXCEPTION={}", e.what())
+ .c_str());
throw e;
}
}