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/channel_auth.cpp b/command/channel_auth.cpp
index 8368412..44d5cad 100644
--- a/command/channel_auth.cpp
+++ b/command/channel_auth.cpp
@@ -1,12 +1,13 @@
#include "channel_auth.hpp"
+#include <errno.h>
#include <ipmid/api.h>
#include <ipmid/types.hpp>
#include <ipmid/utils.hpp>
#include <nlohmann/json.hpp>
#include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <user_channel/channel_layer.hpp>
#include <user_channel/user_layer.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
@@ -120,14 +121,16 @@
std::ifstream jsonFile(configFile);
if (!jsonFile.is_open())
{
- log<level::ERR>("Channel Cipher suites file not found");
+ lg2::error("Channel Cipher suites file not found: {ERROR}", "ERROR",
+ strerror(errno));
elog<InternalFailure>();
}
auto data = Json::parse(jsonFile, nullptr, false);
if (data.is_discarded())
{
- log<level::ERR>("Parsing channel cipher suites JSON failed");
+ lg2::error("Parsing channel cipher suites JSON failed: {ERROR}",
+ "ERROR", strerror(errno));
elog<InternalFailure>();
}
@@ -231,7 +234,8 @@
}
if (!ipmi::isValidPayloadType(static_cast<ipmi::PayloadType>(payloadType)))
{
- log<level::DEBUG>("Get channel cipher suites - Invalid payload type");
+ lg2::debug("Get channel cipher suites - Invalid payload type: {ERROR}",
+ "ERROR", strerror(errno));
constexpr uint8_t ccPayloadTypeNotSupported = 0x80;
return errorResponse(ccPayloadTypeNotSupported);
}
@@ -258,7 +262,8 @@
ipmi::EChannelSessSupported::none) ||
!(ipmi::doesDeviceExist(rspChannel)))
{
- log<level::DEBUG>("Get channel cipher suites - Device does not exist");
+ lg2::debug("Get channel cipher suites - Device does not exist:{ERROR}",
+ "ERROR", strerror(errno));
return errorResponse(IPMI_CC_INVALID_FIELD_REQUEST);
}