crit-service: add failed unit to error log
Whether it's a systemd target or a service, they are both units. Log
that unit name to both error logs so it's easy to tell what failed.
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I32fc45ece1e9ca9b986ead3c9675cf71857b7fcd
diff --git a/systemd_target_signal.cpp b/systemd_target_signal.cpp
index 9f778d5..c44e52f 100644
--- a/systemd_target_signal.cpp
+++ b/systemd_target_signal.cpp
@@ -20,7 +20,8 @@
using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
void SystemdTargetLogging::logError(const std::string& errorLog,
- const std::string& result)
+ const std::string& result,
+ const std::string& unit)
{
auto method = this->bus.new_method_call(
"xyz.openbmc_project.Logging", "/xyz/openbmc_project/logging",
@@ -28,8 +29,9 @@
// Signature is ssa{ss}
method.append(errorLog);
method.append("xyz.openbmc_project.Logging.Entry.Level.Critical");
- method.append(std::array<std::pair<std::string, std::string>, 1>(
- {std::pair<std::string, std::string>({"SYSTEMD_RESULT", result})}));
+ method.append(std::array<std::pair<std::string, std::string>, 2>(
+ {std::pair<std::string, std::string>({"SYSTEMD_RESULT", result}),
+ std::pair<std::string, std::string>({"SYSTEMD_UNIT", unit})}));
try
{
this->bus.call_noreply(method);
@@ -94,7 +96,7 @@
// If this is a monitored error then log it
if (!error.empty())
{
- logError(error, result);
+ logError(error, result, unit);
}
}
return;
diff --git a/systemd_target_signal.hpp b/systemd_target_signal.hpp
index 8674ca5..c46425a 100644
--- a/systemd_target_signal.hpp
+++ b/systemd_target_signal.hpp
@@ -76,8 +76,10 @@
*
* @param[in] error - The error to log
* @param[in] result - The failure code from the systemd unit
+ * @param[in] unit - The name of the failed unit
*/
- void logError(const std::string& error, const std::string& result);
+ void logError(const std::string& error, const std::string& result,
+ const std::string& unit);
/** @brief Check if systemd state change is one to monitor
*