Put state change values into the journal message
On the journal entries that mention host or chassis state changes, put
the actual state in the journal message instead of keeping it in the
metadata. This lets someone debugging state changes avoid having to use
the verbose journal to find the state values.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Ib102d700b692070fae87e525d7b7ccba75d0227b
diff --git a/chassis_state_manager.cpp b/chassis_state_manager.cpp
index 6fa10ee..d970e58 100644
--- a/chassis_state_manager.cpp
+++ b/chassis_state_manager.cpp
@@ -5,6 +5,8 @@
#include "xyz/openbmc_project/Common/error.hpp"
#include "xyz/openbmc_project/State/Shutdown/Power/error.hpp"
+#include <fmt/format.h>
+
#include <cereal/archives/json.hpp>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/log.hpp>
@@ -243,9 +245,9 @@
Chassis::Transition Chassis::requestedPowerTransition(Transition value)
{
- log<level::INFO>("Change to Chassis Requested Power State",
- entry("CHASSIS_REQUESTED_POWER_STATE=%s",
- convertForMessage(value).c_str()));
+ log<level::INFO>(fmt::format("Change to Chassis Requested Power State: {}",
+ convertForMessage(value))
+ .c_str());
executeTransition(value);
return server::Chassis::requestedPowerTransition(value);
}
@@ -253,9 +255,9 @@
Chassis::PowerState Chassis::currentPowerState(PowerState value)
{
PowerState chassisPowerState;
- log<level::INFO>("Change to Chassis Power State",
- entry("CHASSIS_CURRENT_POWER_STATE=%s",
- convertForMessage(value).c_str()));
+ log<level::INFO>(fmt::format("Change to Chassis Power State: {}",
+ convertForMessage(value))
+ .c_str());
chassisPowerState = server::Chassis::currentPowerState(value);
pOHTimer.setEnabled(chassisPowerState == PowerState::On);
diff --git a/host_state_manager.cpp b/host_state_manager.cpp
index a5faa63..82a24f3 100644
--- a/host_state_manager.cpp
+++ b/host_state_manager.cpp
@@ -2,6 +2,7 @@
#include "host_state_manager.hpp"
+#include <fmt/format.h>
#include <systemd/sd-bus.h>
#include <cereal/archives/json.hpp>
@@ -366,10 +367,9 @@
Host::Transition Host::requestedHostTransition(Transition value)
{
- log<level::INFO>("Host State transaction request",
- entry("REQUESTED_HOST_TRANSITION=%s",
- convertForMessage(value).c_str()));
-
+ log<level::INFO>(fmt::format("Host state transition request of {}",
+ convertForMessage(value))
+ .c_str());
// If this is not a power off request then we need to
// decrement the reboot counter. This code should
// never prevent a power on, it should just decrement
@@ -404,8 +404,8 @@
Host::HostState Host::currentHostState(HostState value)
{
log<level::INFO>(
- "Change to Host State",
- entry("CURRENT_HOST_STATE=%s", convertForMessage(value).c_str()));
+ fmt::format("Change to Host State: {}", convertForMessage(value))
+ .c_str());
return server::Host::currentHostState(value);
}