lg2: convert bmc state manager
This is an initial commit to begin moving phosphor-state-manager over to
the new phosphor-logging lg2 interfaces
Do a small commit initially to get any feedback before converting the
rest
Note that lg2 required c++20 which drove a few other minor changes in
this commit as well.
clang-tidy needs to be disabled until we get a version of clang that has
the following fixed:
https://reviews.llvm.org/D99181
Currently it is only in -13 release candidates.
Tested:
- Booted up in QEMU and verified lg2 entries were in journal
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I365965f19a64bd5fd05935d08c8aa487faf015c1
diff --git a/bmc_state_manager.cpp b/bmc_state_manager.cpp
index 2ee58bc..1ce37b3 100644
--- a/bmc_state_manager.cpp
+++ b/bmc_state_manager.cpp
@@ -5,7 +5,7 @@
#include <sys/sysinfo.h>
#include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/exception.hpp>
#include <cassert>
@@ -20,6 +20,8 @@
namespace manager
{
+PHOSPHOR_LOG2_USING;
+
// When you see server:: you know we're referencing our base class
namespace server = sdbusplus::xyz::openbmc_project::State::server;
@@ -56,7 +58,7 @@
}
catch (const sdbusplus::exception::exception& e)
{
- log<level::ERR>("Error in GetUnit call", entry("ERROR=%s", e.what()));
+ error("Error in GetUnit call: {ERROR}", "ERROR", e);
return;
}
@@ -76,16 +78,14 @@
}
catch (const sdbusplus::exception::exception& e)
{
- log<level::INFO>("Error in ActiveState Get",
- entry("ERROR=%s", e.what()));
+ info("Error in ActiveState Get: {ERROR}", "ERROR", e);
return;
}
auto currentStateStr = std::get<std::string>(currentState);
if (currentStateStr == activeState)
{
- log<level::INFO>("Setting the BMCState field",
- entry("CURRENT_BMC_STATE=%s", "BMC_READY"));
+ info("Setting the BMCState field to BMC_READY");
this->currentBMCState(BMCState::Ready);
// Unsubscribe so we stop processing all other signals
@@ -98,14 +98,12 @@
}
catch (const sdbusplus::exception::exception& e)
{
- log<level::INFO>("Error in Unsubscribe",
- entry("ERROR=%s", e.what()));
+ info("Error in Unsubscribe: {ERROR}", "ERROR", e);
}
}
else
{
- log<level::INFO>("Setting the BMCState field",
- entry("CURRENT_BMC_STATE=%s", "BMC_NOTREADY"));
+ info("Setting the BMCState field to BMC_NOTREADY");
this->currentBMCState(BMCState::NotReady);
}
@@ -123,8 +121,7 @@
}
catch (const sdbusplus::exception::exception& e)
{
- log<level::ERR>("Failed to subscribe to systemd signals",
- entry("ERR=%s", e.what()));
+ error("Failed to subscribe to systemd signals: {ERROR}", "ERROR", e);
elog<InternalFailure>();
}
@@ -145,8 +142,7 @@
}
catch (const sdbusplus::exception::exception& e)
{
- log<level::INFO>("Error in HardReboot",
- entry("ERROR=%s", e.what()));
+ info("Error in HardReboot: {ERROR}", "ERROR", e);
}
}
else
@@ -171,8 +167,8 @@
}
catch (const sdbusplus::exception::exception& e)
{
- log<level::INFO>("Error in StartUnit - replace-irreversibly",
- entry("ERROR=%s", e.what()));
+ info("Error in StartUnit - replace-irreversibly: {ERROR}", "ERROR",
+ e);
}
}
return;
@@ -191,7 +187,7 @@
// Caught the signal that indicates the BMC is now BMC_READY
if ((newStateUnit == obmcStandbyTarget) && (newStateResult == signalDone))
{
- log<level::INFO>("BMC_READY");
+ info("BMC_READY");
this->currentBMCState(BMCState::Ready);
// Unsubscribe so we stop processing all other signals
@@ -206,8 +202,7 @@
}
catch (const sdbusplus::exception::exception& e)
{
- log<level::INFO>("Error in Unsubscribe",
- entry("ERROR=%s", e.what()));
+ info("Error in Unsubscribe: {ERROR}", "ERROR", e);
}
}
@@ -216,9 +211,9 @@
BMC::Transition BMC::requestedBMCTransition(Transition value)
{
- log<level::INFO>("Setting the RequestedBMCTransition field",
- entry("REQUESTED_BMC_TRANSITION=0x%s",
- convertForMessage(value).c_str()));
+ info("Setting the RequestedBMCTransition field to "
+ "{REQUESTED_BMC_TRANSITION}",
+ "REQUESTED_BMC_TRANSITION", value);
executeTransition(value);
return server::BMC::requestedBMCTransition(value);
@@ -226,9 +221,9 @@
BMC::BMCState BMC::currentBMCState(BMCState value)
{
- log<level::INFO>(
- "Setting the BMCState field",
- entry("CURRENT_BMC_STATE=0x%s", convertForMessage(value).c_str()));
+
+ info("Setting the BMCState field to {CURRENT_BMC_STATE}",
+ "CURRENT_BMC_STATE", value);
return server::BMC::currentBMCState(value);
}