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;