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/sessions_manager.cpp b/sessions_manager.cpp
index 538aaa4..5c9789b 100644
--- a/sessions_manager.cpp
+++ b/sessions_manager.cpp
@@ -3,7 +3,7 @@
#include "main.hpp"
#include "session.hpp"
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/asio/connection.hpp>
#include <user_channel/channel_layer.hpp>
@@ -12,8 +12,6 @@
#include <iomanip>
#include <memory>
-using namespace phosphor::logging;
-
namespace session
{
@@ -171,7 +169,7 @@
return session;
}
- log<level::INFO>("No free RMCP+ sessions left");
+ lg2::info("No free RMCP+ sessions left");
throw std::runtime_error("No free sessions left");
}
@@ -265,11 +263,10 @@
}
if (!(session->isSessionActive(activeGrace, setupGrace)))
{
- log<level::INFO>(
- "Removing idle IPMI LAN session",
- entry("SESSION_ID=%x", session->getBMCSessionID()),
- entry("HANDLE=%x",
- getSessionHandle(session->getBMCSessionID())));
+ lg2::info(
+ "Removing idle IPMI LAN session, id: {ID}, handler: {HANDLE}",
+ "ID", session->getBMCSessionID(), "HANDLE",
+ getSessionHandle(session->getBMCSessionID()));
sessionHandleMap[getSessionHandle(session->getBMCSessionID())] = 0;
iter = sessionsMap.erase(iter);
}