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/payload_cmds.cpp b/command/payload_cmds.cpp
index 4083209..b3bcca2 100644
--- a/command/payload_cmds.cpp
+++ b/command/payload_cmds.cpp
@@ -7,7 +7,7 @@
#include <ipmid/api.h>
#include <ipmid/api-types.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
namespace sol
{
@@ -15,8 +15,6 @@
namespace command
{
-using namespace phosphor::logging;
-
std::vector<uint8_t> activatePayload(const std::vector<uint8_t>& inPayload,
std::shared_ptr<message::Handler>& handler)
{
@@ -94,7 +92,7 @@
}
catch (const std::exception& e)
{
- log<level::ERR>(e.what());
+ lg2::error("Failed to start SOL payload: {ERROR}", "ERROR", e);
response->completionCode = IPMI_CC_UNSPECIFIED_ERROR;
return outPayload;
}
@@ -161,7 +159,8 @@
}
catch (const std::exception& e)
{
- log<level::INFO>(e.what());
+ lg2::info("Failed to call the activating method: {ERROR}", "ERROR",
+ e);
/*
* In case session has been closed (like in the case of inactivity
* timeout), then activating function would throw an exception,
@@ -173,7 +172,7 @@
}
catch (const std::exception& e)
{
- log<level::ERR>(e.what());
+ lg2::error("Failed to call the getContext method: {ERROR}", "ERROR", e);
response->completionCode = IPMI_CC_UNSPECIFIED_ERROR;
return outPayload;
}