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/manager.cpp b/manager.cpp
index 383d416..ceaed7e 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -6,7 +6,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>
namespace rules = sdbusplus::bus::match::rules;
@@ -84,12 +84,11 @@
try
{
bus.call_noreply(method);
- log<level::INFO>("Updated NTP setting", entry("ENABLED=%d", isNtp));
+ lg2::info("Updated NTP setting: {ENABLED}", "ENABLED", isNtp);
}
catch (const sdbusplus::exception::exception& ex)
{
- log<level::ERR>("Failed to update NTP setting",
- entry("ERR=%s", ex.what()));
+ lg2::error("Failed to update NTP setting: {ERROR}", "ERROR", ex);
}
}
@@ -98,8 +97,7 @@
auto newMode = utils::strToMode(mode);
if (newMode != timeMode)
{
- log<level::INFO>("Time mode is changed",
- entry("MODE=%s", mode.c_str()));
+ lg2::info("Time mode has been changed to {MODE}", "MODE", newMode);
timeMode = newMode;
return true;
}