PLDM: Implementing Phosphor-Logging/LG2 logging
This commit adds changes in PLDM for implementing
structured LG2 logging, thereby moving away from
std::cout/cerr practice of logging which are
output streams and not logging mechanism.
PLDM now can make use of lg2 features like accurate
CODE LINE Number and CODE_FUNCTION Name and better
detailing in json object values which can be used in
log tracking.
More detailed logging change:
https://gist.github.com/riyadixitagra/c251685c1ba84248181891f7bc282395
Tested:
Ran a power off, on, cycle, and reset-reload.
Change-Id: I0485035f15f278c3fd172f0581b053c1c37f3a5b
Signed-off-by: Riya Dixit <riyadixitagra@gmail.com>
diff --git a/oem/ibm/libpldmresponder/file_table.cpp b/oem/ibm/libpldmresponder/file_table.cpp
index 594adc7..5c2a2da 100644
--- a/oem/ibm/libpldmresponder/file_table.cpp
+++ b/oem/ibm/libpldmresponder/file_table.cpp
@@ -2,30 +2,31 @@
#include <libpldm/utils.h>
+#include <phosphor-logging/lg2.hpp>
+
#include <fstream>
#include <iostream>
+PHOSPHOR_LOG2_USING;
+
namespace pldm
{
-
namespace filetable
{
-
FileTable::FileTable(const std::string& fileTableConfigPath)
{
std::ifstream jsonFile(fileTableConfigPath);
if (!jsonFile.is_open())
{
- std::cerr << "File table config file does not exist, FILE="
- << fileTableConfigPath.c_str() << "\n";
+ error("File table config file does not exist, FILE={TABLE_CONFIG_PATH}",
+ "TABLE_CONFIG_PATH", fileTableConfigPath.c_str());
return;
}
auto data = Json::parse(jsonFile, nullptr, false);
if (data.is_discarded())
{
- std::cerr << "Parsing config file failed"
- << "\n";
+ error("Parsing config file failed");
return;
}