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/host-bmc/dbus_to_event_handler.cpp b/host-bmc/dbus_to_event_handler.cpp
index cf3064e..d1125f1 100644
--- a/host-bmc/dbus_to_event_handler.cpp
+++ b/host-bmc/dbus_to_event_handler.cpp
@@ -4,6 +4,10 @@
#include <libpldm/pldm.h>
+#include <phosphor-logging/lg2.hpp>
+
+PHOSPHOR_LOG2_USING;
+
namespace pldm
{
using namespace pldm::dbus_api;
@@ -40,8 +44,8 @@
if (rc != PLDM_SUCCESS)
{
requester.markFree(mctp_eid, instanceId);
- std::cerr << "Failed to encode_platform_event_message_req, rc = " << rc
- << std::endl;
+ error("Failed to encode_platform_event_message_req, rc = {RC}", "RC",
+ rc);
return;
}
@@ -50,8 +54,7 @@
size_t respMsgLen) {
if (response == nullptr || !respMsgLen)
{
- std::cerr
- << "Failed to receive response for platform event message \n";
+ error("Failed to receive response for platform event message");
return;
}
uint8_t completionCode{};
@@ -60,10 +63,9 @@
&completionCode, &status);
if (rc || completionCode)
{
- std::cerr << "Failed to decode_platform_event_message_resp: "
- << "rc=" << rc
- << ", cc=" << static_cast<unsigned>(completionCode)
- << std::endl;
+ error(
+ "Failed to decode_platform_event_message_resp: rc = {RC}, cc = {CC}",
+ "RC", rc, "CC", static_cast<unsigned>(completionCode));
}
};
@@ -72,7 +74,7 @@
std::move(requestMsg), std::move(platformEventMessageResponseHandler));
if (rc)
{
- std::cerr << "Failed to send the platform event message \n";
+ error("Failed to send the platform event message");
}
}