lg2: convert state-manager
This converts the rest of phosphor-state-manager over to the lg2
interface.
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I3878ec950b6a2b1ada93544cc021cecf14edfb46
diff --git a/scheduled_host_transition.cpp b/scheduled_host_transition.cpp
index f2907c5..dd83f4a 100644
--- a/scheduled_host_transition.cpp
+++ b/scheduled_host_transition.cpp
@@ -8,7 +8,7 @@
#include <cereal/archives/json.hpp>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <xyz/openbmc_project/ScheduledTime/error.hpp>
#include <chrono>
@@ -31,6 +31,8 @@
namespace manager
{
+PHOSPHOR_LOG2_USING;
+
namespace fs = std::filesystem;
using namespace std::chrono;
@@ -52,8 +54,8 @@
if (timer.isEnabled())
{
timer.setEnabled(false);
- log<level::DEBUG>("scheduledTime: The function Scheduled Host "
- "Transition is disabled.");
+ debug("scheduledTime: The function Scheduled Host Transition is "
+ "disabled.");
}
}
else
@@ -61,9 +63,8 @@
auto deltaTime = seconds(value) - getTime();
if (deltaTime < seconds(0))
{
- log<level::ERR>(
- "Scheduled time is earlier than current time. Fail to "
- "schedule host transition.");
+ error("Scheduled time is earlier than current time. Fail to "
+ "schedule host transition.");
elog<InvalidTimeError>(
InvalidTime::REASON("Scheduled time is in the past"));
}
@@ -97,8 +98,8 @@
utils::setProperty(bus, hostPath, HOST_BUSNAME, PROPERTY_TRANSITION,
reqTrans);
- log<level::INFO>("Set requestedTransition",
- entry("REQUESTED_TRANSITION=%s", reqTrans.c_str()));
+ info("Set requestedTransition to {REQUESTED_TRANSITION}",
+ "REQUESTED_TRANSITION", reqTrans);
}
void ScheduledHostTransition::callback()
@@ -126,8 +127,8 @@
if (timeFd == -1)
{
auto eno = errno;
- log<level::ERR>("Failed to create timerfd", entry("ERRNO=%d", eno),
- entry("RC=%d", timeFd));
+ error("Failed to create timerfd, errno: {ERRNO}, rc: {RC}", "ERRNO",
+ eno, "RC", timeFd);
throw std::system_error(eno, std::system_category());
}
@@ -141,8 +142,8 @@
if (r != 0)
{
auto eno = errno;
- log<level::ERR>("Failed to set timerfd", entry("ERRNO=%d", eno),
- entry("RC=%d", r));
+ error("Failed to set timerfd, errno: {ERRNO}, rc: {RC}", "ERRNO", eno,
+ "RC", r);
throw std::system_error(eno, std::system_category());
}
@@ -153,8 +154,8 @@
if (r < 0)
{
auto eno = errno;
- log<level::ERR>("Failed to add event", entry("ERRNO=%d", eno),
- entry("RC=%d", r));
+ error("Failed to add event, errno: {ERRNO}, rc: {RC}", "ERRNO", eno,
+ "RC", r);
throw std::system_error(eno, std::system_category());
}
timeChangeEventSource.reset(es);
@@ -180,8 +181,8 @@
if (schedTime == 0)
{
- log<level::DEBUG>("handleTimeUpdates: The function Scheduled Host "
- "Transition is disabled.");
+ debug("handleTimeUpdates: The function Scheduled Host Transition is "
+ "disabled.");
return;
}
@@ -213,7 +214,7 @@
while (read(fd, time.data(), time.max_size()) > 0)
;
- log<level::DEBUG>("BMC system time is changed");
+ debug("BMC system time is changed");
schedHostTran->handleTimeUpdates();
return 0;
@@ -246,7 +247,7 @@
}
catch (std::exception& e)
{
- log<level::ERR>(e.what());
+ error("deserialize exception: {ERROR}", "ERROR", e);
fs::remove(path);
}