logging: switch to lg2
After switching to C++20, 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: I7de1e3782363c0c7f57ff917cf9487e4599cac8e
diff --git a/mslverify/util.hpp b/mslverify/util.hpp
index 3792908..6ee1e81 100644
--- a/mslverify/util.hpp
+++ b/mslverify/util.hpp
@@ -2,7 +2,7 @@
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/message.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
@@ -44,11 +44,8 @@
if (respMsg.is_method_error())
{
- phosphor::logging::log<phosphor::logging::level::INFO>(
- "Failed to invoke DBus method.",
- phosphor::logging::entry("PATH=%s", path.c_str()),
- phosphor::logging::entry("INTERFACE=%s", interface.c_str()),
- phosphor::logging::entry("METHOD=%s", method.c_str()));
+ lg2::error("Failed to invoke DBus method. {PATH}, {INTF}, {METHOD}",
+ "PATH", path, "INTF", interface, "METHOD", method);
phosphor::logging::elog<detail::errors::InternalFailure>();
}
@@ -105,10 +102,8 @@
if (mapperResp.empty())
{
- phosphor::logging::log<phosphor::logging::level::INFO>(
- "Object not found.",
- phosphor::logging::entry("PATH=%s", path.c_str()),
- phosphor::logging::entry("INTERFACE=%s", interface.c_str()));
+ lg2::error("Object not found. {PATH}, {INTF}", "PATH", path, "INTF",
+ interface);
phosphor::logging::elog<detail::errors::InternalFailure>();
}
return mapperResp.begin()->first;
diff --git a/mslverify/verify.cpp b/mslverify/verify.cpp
index f86ed1f..d322b8b 100644
--- a/mslverify/verify.cpp
+++ b/mslverify/verify.cpp
@@ -92,9 +92,8 @@
if (!result)
{
- phosphor::logging::log<phosphor::logging::level::INFO>(
- "The physical system configuration does not "
- "satisfy the minimum ship level.");
+ lg2::info(
+ "The physical system configuration does not satisfy the minimum ship level.");
return 1;
}