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/libpldmresponder/pdr_utils.hpp b/libpldmresponder/pdr_utils.hpp
index 44ac008..6c1264a 100644
--- a/libpldmresponder/pdr_utils.hpp
+++ b/libpldmresponder/pdr_utils.hpp
@@ -7,6 +7,7 @@
#include <stdint.h>
#include <nlohmann/json.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
#include <filesystem>
@@ -15,6 +16,8 @@
#include <iostream>
#include <string>
+PHOSPHOR_LOG2_USING;
+
using InternalFailure =
sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
@@ -22,13 +25,10 @@
namespace pldm
{
-
namespace responder
{
-
namespace pdr_utils
{
-
/** @struct Type ID associated with pdr
*
*/
@@ -81,7 +81,8 @@
std::ifstream jsonFile(path);
if (!jsonFile.is_open())
{
- std::cerr << "Error opening PDR JSON file, PATH=" << path << "\n";
+ error("Error opening PDR JSON file, PATH={JSON_PATH}", "JSON_PATH",
+ path);
return {};
}