logging: switch to lg2
It is recommended to use `phosphor::lg2` to format log, and the
correct `CODE_LINE` and `CODE_FUNC` values can be used in log
tracking.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Ic8a400451f96cde5bdb9f47094806bd31adce7d9
diff --git a/bmc_epoch.cpp b/bmc_epoch.cpp
index 7eeee32..5889ed3 100644
--- a/bmc_epoch.cpp
+++ b/bmc_epoch.cpp
@@ -7,7 +7,7 @@
#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/Common/error.hpp>
// Need to do this since its not exported outside of the kernel.
@@ -47,8 +47,7 @@
timeFd = timerfd_create(CLOCK_REALTIME, 0);
if (timeFd == -1)
{
- log<level::ERR>("Failed to create timerfd", entry("ERRNO=%d", errno),
- entry("ERR=%s", strerror(errno)));
+ lg2::error("Failed to create timerfd: {ERRNO}", "ERRNO", errno);
elog<InternalFailure>();
}
@@ -56,8 +55,7 @@
timeFd, TFD_TIMER_ABSTIME | TFD_TIMER_CANCEL_ON_SET, &maxTime, nullptr);
if (r != 0)
{
- log<level::ERR>("Failed to set timerfd", entry("ERRNO=%d", errno),
- entry("ERR=%s", strerror(errno)));
+ lg2::error("Failed to set timerfd: {ERRNO}", "ERRNO", errno);
elog<InternalFailure>();
}
@@ -66,8 +64,7 @@
this);
if (r < 0)
{
- log<level::ERR>("Failed to add event", entry("ERRNO=%d", -r),
- entry("ERR=%s", strerror(-r)));
+ lg2::error("Failed to add event: {ERRNO}", "ERRNO", errno);
elog<InternalFailure>();
}
timeChangeEventSource.reset(es);