user_channel: switch to lg2
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
Change-Id: I80149836f196f01eb09cc874f74eec0d787b5ac5
diff --git a/user_channel/cipher_mgmt.cpp b/user_channel/cipher_mgmt.cpp
index a2f024b..f1bc543 100644
--- a/user_channel/cipher_mgmt.cpp
+++ b/user_channel/cipher_mgmt.cpp
@@ -20,7 +20,7 @@
#include <sys/types.h>
#include <unistd.h>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <filesystem>
#include <fstream>
@@ -28,7 +28,6 @@
namespace ipmi
{
-using namespace phosphor::logging;
using Json = nlohmann::json;
namespace fs = std::filesystem;
@@ -51,7 +50,7 @@
{
if (!fs::exists(cipherSuiteDefaultPrivFileName))
{
- log<level::ERR>("CS privilege levels default file does not exist...");
+ lg2::error("CS privilege levels default file does not exist...");
}
else
{
@@ -98,7 +97,7 @@
std::ifstream jsonFile(csFileName);
if (!jsonFile.good())
{
- log<level::ERR>("JSON file not found");
+ lg2::error("JSON file not found");
return nullptr;
}
@@ -109,8 +108,9 @@
}
catch (const Json::parse_error& e)
{
- log<level::ERR>("Corrupted cipher suite privilege levels config file.",
- entry("MSG: %s", e.what()));
+ lg2::error(
+ "Corrupted cipher suite privilege levels config file: {ERROR}",
+ "ERROR", e);
}
return data;
@@ -129,8 +129,8 @@
if (fd < 0)
{
- log<level::ERR>("Error opening CS privilege level config file",
- entry("FILE_NAME=%s", tmpFile.c_str()));
+ lg2::error("Error opening CS privilege level config file: {FILE_NAME}",
+ "FILE_NAME", tmpFile);
return -EIO;
}
const auto& writeData = jsonData.dump();
@@ -138,8 +138,8 @@
static_cast<ssize_t>(writeData.size()))
{
close(fd);
- log<level::ERR>("Error writing CS privilege level config file",
- entry("FILE_NAME=%s", tmpFile.c_str()));
+ lg2::error("Error writing CS privilege level config file: {FILE_NAME}",
+ "FILE_NAME", tmpFile);
unlink(tmpRandomFile.data());
return -EIO;
}
@@ -147,8 +147,8 @@
if (std::rename(tmpRandomFile.data(), cipherSuitePrivFileName.c_str()))
{
- log<level::ERR>("Error renaming CS privilege level config file",
- entry("FILE_NAME=%s", tmpFile.c_str()));
+ lg2::error("Error renaming CS privilege level config file: {FILE_NAME}",
+ "FILE_NAME", tmpFile);
unlink(tmpRandomFile.data());
return -EIO;
}
@@ -161,8 +161,7 @@
auto iter = std::find(ipmi::privList.begin(), ipmi::privList.end(), value);
if (iter == privList.end())
{
- log<level::ERR>("Invalid privilege.",
- entry("PRIV_STR=%s", value.c_str()));
+ lg2::error("Invalid privilege: {PRIV_STR}", "PRIV_STR", value);
return ccUnspecifiedError;
}
@@ -179,7 +178,7 @@
{
if (!isValidChannel(chNum))
{
- log<level::ERR>("Invalid channel number", entry("CHANNEL=%u", chNum));
+ lg2::error("Invalid channel number: {CHANNEL}", "CHANNEL", chNum);
return ccInvalidFieldRequest;
}
@@ -195,15 +194,15 @@
{
if (!isValidChannel(chNum))
{
- log<level::ERR>("Invalid channel number", entry("CHANNEL=%u", chNum));
+ lg2::error("Invalid channel number: {CHANNEL}", "CHANNEL", chNum);
return ccInvalidFieldRequest;
}
Json jsonData;
if (!fs::exists(cipherSuitePrivFileName))
{
- log<level::INFO>("CS privilege levels user settings file does not "
- "exist. Creating...");
+ lg2::info("CS privilege levels user settings file does not "
+ "exist. Creating...");
}
else
{
@@ -234,7 +233,7 @@
if (writeCSPrivilegeLevels(jsonData))
{
- log<level::ERR>("Error in setting CS Privilege Levels.");
+ lg2::error("Error in setting CS Privilege Levels.");
return ccUnspecifiedError;
}