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: I4aabaafe997e13c10d655a83a9ef0071ad11126e
diff --git a/command/guid.cpp b/command/guid.cpp
index 56b459f..253a2dc 100644
--- a/command/guid.cpp
+++ b/command/guid.cpp
@@ -3,7 +3,7 @@
#include <ipmid/api.h>
#include <mapper.h>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <sstream>
#include <string>
@@ -45,9 +45,8 @@
int rc = mapper_get_service(bus, guidObjPath, &busname);
if (rc < 0)
{
- log<level::ERR>("Failed to get bus name",
- entry("PATH=%s", guidObjPath),
- entry("ERROR=%s", strerror(-rc)));
+ lg2::error("Failed to get bus name, path: {PATH}, error: {ERROR}",
+ "PATH", guidObjPath, "ERROR", strerror(-rc));
break;
}
@@ -55,16 +54,16 @@
&error, &reply, "ss", chassisIntf, "uuid");
if (rc < 0)
{
- log<level::ERR>("Failed to call Get Method",
- entry("ERROR=%s", strerror(-rc)));
+ lg2::error("Failed to call Get Method: {ERROR}", "ERROR",
+ strerror(-rc));
break;
}
rc = sd_bus_message_read(reply, "v", "s", &uuid);
if (rc < 0 || uuid == NULL)
{
- log<level::ERR>("Failed to get a response",
- entry("ERROR=%s", strerror(-rc)));
+ lg2::error("Failed to get a response: {ERROR}", "ERROR",
+ strerror(-rc));
break;
}