PLDM: Implementing Phosphor-Logging/LG2 logging
This commit migrates std::cerr/cout added as part
of new changes in PLDM to LG2.
Change-Id: I8e85732684d47b6740521e95712433a7c6760d8a
Signed-off-by: Riya Dixit <riyadixitagra@gmail.com>
diff --git a/libpldmresponder/bios_integer_attribute.cpp b/libpldmresponder/bios_integer_attribute.cpp
index 6611389..258a188 100644
--- a/libpldmresponder/bios_integer_attribute.cpp
+++ b/libpldmresponder/bios_integer_attribute.cpp
@@ -37,7 +37,7 @@
if (rc != PLDM_SUCCESS)
{
error(
- "Wrong filed for integer attribute, ATTRIBUTE_NAME={ATTR_NAME} ERRMSG= {ERR_MSG} LOWER_BOUND={LOW_BOUND} UPPER_BOUND={UPPER_BOUND} DEFAULT_VALUE={DEF_VAL} SCALAR_INCREMENT={SCALAR_INCREMENT}",
+ "Wrong field for integer attribute, ATTRIBUTE_NAME={ATTR_NAME} ERRMSG= {ERR_MSG} LOWER_BOUND={LOW_BOUND} UPPER_BOUND={UPPER_BOUND} DEFAULT_VALUE={DEF_VAL} SCALAR_INCREMENT={SCALAR_INCREMENT}",
"ATTR_NAME", attr.c_str(), "ERR_MSG", errmsg, "LOW_BOUND",
integerInfo.lowerBound, "UPPER_BOUND", integerInfo.upperBound,
"DEF_VAL", integerInfo.defaultValue, "SCALAR_INCREMENT",
diff --git a/libpldmresponder/fru.cpp b/libpldmresponder/fru.cpp
index a716f5d..98f696c 100644
--- a/libpldmresponder/fru.cpp
+++ b/libpldmresponder/fru.cpp
@@ -65,7 +65,7 @@
while (!tmpObj.empty())
{
std::string s = tmpObj.top();
- std::cout << s << std::endl;
+ info("{TMP_OBJ_STR}", "TMP_OBJ_PATH", s);
tmpObj.pop();
}
// Update pldm entity to assocition tree
@@ -208,7 +208,7 @@
}
catch (const std::exception& e)
{
- info(
+ error(
"Config JSONs missing for the item interface type, interface = {INTF}",
"INTF", interface.first);
break;
diff --git a/libpldmresponder/pdr_numeric_effecter.hpp b/libpldmresponder/pdr_numeric_effecter.hpp
index 0347af4..88d7f8a 100644
--- a/libpldmresponder/pdr_numeric_effecter.hpp
+++ b/libpldmresponder/pdr_numeric_effecter.hpp
@@ -78,8 +78,7 @@
// present
if (!pdr->entity_type)
{
- std::cerr << "The entity path for the FRU is not present."
- << std::endl;
+ error("The entity path for the FRU is not present.");
continue;
}
}
diff --git a/libpldmresponder/pdr_state_effecter.hpp b/libpldmresponder/pdr_state_effecter.hpp
index 1dc2250..2a6f86e 100644
--- a/libpldmresponder/pdr_state_effecter.hpp
+++ b/libpldmresponder/pdr_state_effecter.hpp
@@ -96,8 +96,7 @@
// present
if (!pdr->entity_type)
{
- std::cerr << "The entity path for the FRU is not present."
- << std::endl;
+ error("The entity path for the FRU is not present.");
continue;
}
}
diff --git a/libpldmresponder/pdr_state_sensor.hpp b/libpldmresponder/pdr_state_sensor.hpp
index bda3964..b75757e 100644
--- a/libpldmresponder/pdr_state_sensor.hpp
+++ b/libpldmresponder/pdr_state_sensor.hpp
@@ -99,8 +99,7 @@
// present
if (!pdr->entity_type)
{
- std::cerr << "The entity path for the FRU is not present."
- << std::endl;
+ error("The entity path for the FRU is not present.");
continue;
}
}
diff --git a/libpldmresponder/test/libpldmresponder_platform_test.cpp b/libpldmresponder/test/libpldmresponder_platform_test.cpp
index 0c9b324..a646f9d 100644
--- a/libpldmresponder/test/libpldmresponder_platform_test.cpp
+++ b/libpldmresponder/test/libpldmresponder_platform_test.cpp
@@ -197,13 +197,10 @@
// current is not what we want
pldm_pdr_hdr* hdr = reinterpret_cast<pldm_pdr_hdr*>(resp->record_data);
- std::cerr << "PDR next record handle " << handle << "\n";
- std::cerr << "PDR type " << hdr->type << "\n";
if (hdr->type == PLDM_STATE_EFFECTER_PDR)
{
pldm_state_effecter_pdr* pdr =
reinterpret_cast<pldm_state_effecter_pdr*>(resp->record_data);
- std::cerr << "PDR entity type " << pdr->entity_type << "\n";
if (pdr->entity_type == 100)
{
found = true;
diff --git a/oem/ibm/libpldmresponder/file_io_type_vpd.cpp b/oem/ibm/libpldmresponder/file_io_type_vpd.cpp
index 783683e..9c14c33 100644
--- a/oem/ibm/libpldmresponder/file_io_type_vpd.cpp
+++ b/oem/ibm/libpldmresponder/file_io_type_vpd.cpp
@@ -7,8 +7,12 @@
#include <stdint.h>
+#include <phosphor-logging/lg2.hpp>
+
#include <iostream>
+PHOSPHOR_LOG2_USING;
+
typedef uint8_t byte;
namespace pldm
@@ -39,16 +43,17 @@
}
catch (const std::exception& e)
{
- std::cerr << "Get keyword error from dbus interface : "
- << keywrdInterface << " ERROR= " << e.what() << std::endl;
+ error(
+ "Get keyword error from dbus interface :{KEYWORD_INTF} ERROR={ERR_EXCEP}",
+ "KEYWORD_INTF", keywrdInterface, "ERR_EXCEP", e.what());
}
uint32_t keywrdSize = std::get<std::vector<byte>>(keywrd).size();
-
if (length < keywrdSize)
{
- std::cerr << "length requested is less the keyword size, length: "
- << length << " keyword size: " << keywrdSize << std::endl;
+ error(
+ "length requested is less the keyword size, length:{LEN} keyword size:{KEYWORD_SIZE}",
+ "LEN", length, "KEYWORD_SIZE", keywrdSize);
return PLDM_ERROR_INVALID_DATA;
}
@@ -67,8 +72,8 @@
auto fd = open(keywrdFilePath, std::ios::out | std::ofstream::binary);
if (!keywrdFile)
{
- std::cerr << "VPD keyword file open error: " << keywrdFilePath
- << " errno: " << errno << std::endl;
+ error("VPD keyword file open error: {KEYWORD_FILE_PATH} errno: {ERR}",
+ "KEYWORD_FILE_PATH", keywrdFilePath, "ERR", errno);
pldm::utils::reportError(
"xyz.openbmc_project.PLDM.Error.readKeywordHandler.keywordFileOpenError");
return PLDM_ERROR;
@@ -76,20 +81,19 @@
if (offset > keywrdSize)
{
- std::cerr << "Offset exceeds file size, OFFSET=" << offset
- << " FILE_SIZE=" << keywrdSize << std::endl;
+ error("Offset exceeds file size, OFFSET={OFFSET} FILE_SIZE={FILE_SIZE}",
+ "OFFSET", offset, "FILE_SIZE", keywrdSize);
return PLDM_DATA_OUT_OF_RANGE;
}
- // length of keyword data should be same as keyword data size in dbus object
+ // length of keyword data should be same as keyword data size in dbus
+ // object
length = static_cast<uint32_t>(keywrdSize) - offset;
auto returnCode = lseek(fd, offset, SEEK_SET);
if (returnCode == -1)
{
- std::cerr
- << "Could not find keyword data at given offset. File Seek failed"
- << std::endl;
+ error("Could not find keyword data at given offset. File Seek failed");
return PLDM_ERROR;
}
@@ -97,8 +101,8 @@
keywrdSize);
if (keywrdFile.bad())
{
- std::cerr << "Error while writing to file: " << keywrdFilePath
- << std::endl;
+ error("Error while writing to file: {KEYWORD_FILE_PATH}",
+ "KEYWORD_FILE_PATH", keywrdFilePath);
}
keywrdFile.close();
@@ -106,8 +110,8 @@
fs::remove(keywrdFilePath);
if (rc)
{
- std::cerr << "Read error for keyword file with size: " << keywrdSize
- << std::endl;
+ error("Read error for keyword file with size: {KEYWORD_SIZE}",
+ "KEYWORD_SIZE", keywrdSize);
pldm::utils::reportError(
"xyz.openbmc_project.PLDM.Error.readKeywordHandler.keywordFileReadError");
return PLDM_ERROR;
diff --git a/pldmd/pldmd.cpp b/pldmd/pldmd.cpp
index 11c4ec2..b8315b7 100644
--- a/pldmd/pldmd.cpp
+++ b/pldmd/pldmd.cpp
@@ -148,9 +148,9 @@
void optionUsage(void)
{
- error("Usage: pldmd [options]");
- error("Options:");
- error(" [--verbose] - would enable verbosity");
+ info("Usage: pldmd [options]");
+ info("Options:");
+ info(" [--verbose] - would enable verbosity");
}
int main(int argc, char** argv)