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.
Tested: built phosphor-srvcfg-manager successfully and Unit Test
passes.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Ib676a0d8082b0e3e72b51bd5115bf5b05599e6ec
diff --git a/src/main.cpp b/src/main.cpp
index 1d9ebed..5723de2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -220,8 +220,8 @@
const std::vector<ListUnitsType>& listUnits) {
if (ec)
{
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "async_method_call error: ListUnits failed");
+ lg2::error("async_method_call error: ListUnits failed: {EC}",
+ "EC", ec.value());
return;
}
handleListUnitsResponse(server, conn, ec, listUnits);
@@ -238,8 +238,8 @@
const std::variant<uint64_t>& value) {
if (ec)
{
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "async_method_call error: ListUnits failed");
+ lg2::error("async_method_call error: ListUnits failed: {EC}",
+ "EC", ec.value());
return;
}
if (std::get<uint64_t>(value))
@@ -267,8 +267,9 @@
}
if (ec)
{
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "service config mgr - init - async wait error.");
+ lg2::error(
+ "service config mgr - init - async wait error: {EC}",
+ "EC", ec.value());
return;
}
checkAndInit(server, conn);