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/message_handler.cpp b/message_handler.cpp
index f845228..b7314b8 100644
--- a/message_handler.cpp
+++ b/message_handler.cpp
@@ -8,17 +8,14 @@
#include <sys/socket.h>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <memory>
#include <string>
#include <vector>
-using namespace phosphor::logging;
-
namespace message
{
-using namespace phosphor::logging;
bool Handler::receive()
{
@@ -31,7 +28,7 @@
// Read of the packet failed
if (readStatus < 0)
{
- log<level::ERR>("Error in Read", entry("STATUS=%x", readStatus));
+ lg2::error("Error in Read status: {STATUS}", "STATUS", readStatus);
return false;
}
@@ -82,8 +79,7 @@
catch (const std::exception& e)
{
// send failed, most likely due to a session closure
- log<level::INFO>("Async RMCP+ reply failed",
- entry("EXCEPTION=%s", e.what()));
+ lg2::info("Async RMCP+ reply failed: {ERROR}", "ERROR", e);
}
}