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.cpp b/libpldmresponder/pdr_utils.cpp
index fb7ffd6..89bcba8 100644
--- a/libpldmresponder/pdr_utils.cpp
+++ b/libpldmresponder/pdr_utils.cpp
@@ -3,19 +3,20 @@
#include <config.h>
#include <libpldm/platform.h>
+#include <phosphor-logging/lg2.hpp>
+
#include <climits>
+PHOSPHOR_LOG2_USING;
+
using namespace pldm::pdr;
namespace pldm
{
-
namespace responder
{
-
namespace pdr_utils
{
-
pldm_pdr* Repo::getPdr() const
{
return repo;
@@ -80,10 +81,9 @@
StatestoDbusVal valueMap;
if (dBusValues.size() != pv.size())
{
- std::cerr
- << "dBusValues size is not equal to pv size, dBusValues Size: "
- << dBusValues.size() << ", pv Size: " << pv.size() << "\n";
-
+ error(
+ "dBusValues size is not equal to pv size, dBusValues Size: {DBUS_VAL_SIZE}, pv Size: {PV_SIZE}",
+ "DBUS_VAL_SIZE", dBusValues.size(), "PV_SIZE", pv.size());
return {};
}
@@ -131,8 +131,8 @@
}
else
{
- std::cerr << "Unknown D-Bus property type, TYPE=" << type.c_str()
- << "\n";
+ error("Unknown D-Bus property type, TYPE={OTHER_TYPE}",
+ "OTHER_TYPE", type.c_str());
return {};
}