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_io.hpp b/oem/ibm/libpldmresponder/file_io.hpp
index 769e716..ddde7f8 100644
--- a/oem/ibm/libpldmresponder/file_io.hpp
+++ b/oem/ibm/libpldmresponder/file_io.hpp
@@ -17,17 +17,20 @@
#include <sys/types.h>
#include <unistd.h>
+#include <phosphor-logging/lg2.hpp>
+
#include <filesystem>
#include <iostream>
#include <vector>
+PHOSPHOR_LOG2_USING;
+
namespace pldm
{
namespace responder
{
namespace dma
{
-
// The minimum data size of dma transfer in bytes
constexpr uint32_t minSize = 16;
@@ -116,7 +119,8 @@
int file = open(path.string().c_str(), flags);
if (file == -1)
{
- std::cerr << "File does not exist, path = " << path.string() << "\n";
+ error("File does not exist, path = {FILE_PATH}", "FILE_PATH",
+ path.string());
encode_rw_file_memory_resp(instanceId, command, PLDM_ERROR, 0,
responsePtr);
return response;