pseq: Add logging of power on/off timeout entries
When power on or power off times out, create log entries.
Signed-off-by: Jim Wright <jlwright@us.ibm.com>
Change-Id: I458f43c3c44f0540819d71e3b55309d486e8e62d
diff --git a/phosphor-power-sequencer/src/power_control.cpp b/phosphor-power-sequencer/src/power_control.cpp
index 7426932..981a957 100644
--- a/phosphor-power-sequencer/src/power_control.cpp
+++ b/phosphor-power-sequencer/src/power_control.cpp
@@ -20,6 +20,8 @@
#include "utility.hpp"
#include <fmt/format.h>
+#include <sys/types.h>
+#include <unistd.h>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/elog.hpp>
@@ -73,6 +75,35 @@
{
log<level::ERR>("ERROR PowerControl: Pgood poll timeout");
inStateTransition = false;
+
+ try
+ {
+ auto method = bus.new_method_call(
+ "xyz.openbmc_project.Logging",
+ "/xyz/openbmc_project/logging",
+ "xyz.openbmc_project.Logging.Create", "Create");
+
+ std::map<std::string, std::string> additionalData;
+ // Add PID to AdditionalData
+ additionalData.emplace("_PID", std::to_string(getpid()));
+
+ method.append(
+ state ? "xyz.openbmc_project.Power.Error.PowerOnTimeout"
+ : "xyz.openbmc_project.Power.Error.PowerOffTimeout",
+ sdbusplus::xyz::openbmc_project::Logging::server::Entry::
+ Level::Critical,
+ additionalData);
+ bus.call_noreply(method);
+ }
+ catch (const std::exception& e)
+ {
+ log<level::ERR>(
+ fmt::format(
+ "Unable to log timeout error, state: {}, error {}",
+ state, e.what())
+ .c_str());
+ }
+
return;
}
}