libpldmresponder: Improving Logs (lg2)
This commit corrects the severity level of logs and also formats the
message string, fixing the ill-defined message string of the logs as
mentioned in the anti-pattern document [1]. Additionally, based on the
requirement this commit adds more debug information to logs.
[1]: https://github.com/openbmc/docs/blob/master/anti-patterns.md#ill-defined-data-structuring-in-lg2-message-strings
Change-Id: I7dc5c308a8cd76573995e07d01d1a6037bca31ba
Signed-off-by: Riya Dixit <riyadixitagra@gmail.com>
diff --git a/libpldmresponder/platform.cpp b/libpldmresponder/platform.cpp
index 2a19e66..be554dd 100644
--- a/libpldmresponder/platform.cpp
+++ b/libpldmresponder/platform.cpp
@@ -70,7 +70,8 @@
{
for (const auto& directory : dir)
{
- info("checking if : {DIR} exists", "DIR", directory);
+ info("Checking if directory '{DIRECTORY}' exists", "DIRECTORY",
+ directory);
if (!fs::exists(directory))
{
return;
@@ -136,20 +137,22 @@
catch (const InternalFailure& e)
{
error(
- "PDR config directory '{PATH}' does not exist or empty for '{TYPE}' pdr: {ERROR}",
- "TYPE", pdrType, "PATH", dirEntry.path(), "ERROR", e);
+ "PDR config directory '{PATH}' does not exist or empty for '{TYPE}' pdr, error - {ERROR}",
+ "PATH", dirEntry.path(), "TYPE", pdrType, "ERROR", e);
}
catch (const Json::exception& e)
{
- error("Failed parsing PDR JSON file for '{TYPE}' pdr: {ERROR}",
- "TYPE", pdrType, "ERROR", e);
+ error(
+ "Failed to parse PDR JSON file for '{TYPE}' pdr, error - {ERROR}",
+ "TYPE", pdrType, "ERROR", e);
pldm::utils::reportError(
"xyz.openbmc_project.PLDM.Error.Generate.PDRJsonFileParseFail");
}
catch (const std::exception& e)
{
- error("Failed parsing PDR JSON file for '{TYPE}' pdr: {ERROR}",
- "TYPE", pdrType, "ERROR", e);
+ error(
+ "Failed to parse PDR JSON file for '{TYPE}' pdr, error - {ERROR}",
+ "TYPE", pdrType, "ERROR", e);
pldm::utils::reportError(
"xyz.openbmc_project.PLDM.Error.Generate.PDRJsonFileParseFail");
}
@@ -269,8 +272,9 @@
}
catch (const std::exception& e)
{
- error("Error accessing PDR, HANDLE={REC_HANDLE} ERROR={ERR_EXCEP}",
- "REC_HANDLE", recordHandle, "ERR_EXCEP", e.what());
+ error(
+ "Failed to access PDR record handle '{RECORD_HANDLE}', error - {ERROR}",
+ "RECORD_HANDLE", recordHandle, "ERROR", e);
return CmdHandler::ccOnlyResponse(request, PLDM_ERROR);
}
return response;
@@ -387,7 +391,8 @@
}
catch (const std::out_of_range& e)
{
- error("Error in handling platform event msg: {ERROR}", "ERROR", e);
+ error("Failed to handle platform event msg, error - {ERROR}",
+ "ERROR", e);
return CmdHandler::ccOnlyResponse(request, PLDM_ERROR_INVALID_DATA);
}
}
@@ -683,8 +688,8 @@
if (rc != PLDM_SUCCESS)
{
error(
- "Reponse to GetNumericEffecterValue failed RC={RC} for EffectorId={EFFECTER_ID} ",
- "RC", rc, "EFFECTER_ID", effecterId);
+ "Failed to get response of GetNumericEffecterValue for effecter ID '{EFFECTERID}', response code '{RC}'.",
+ "EFFECTERID", effecterId, "RC", rc);
return ccOnlyResponse(request, rc);
}
return response;
@@ -872,9 +877,9 @@
if (sensorRearmCount > tmpCompSensorCnt)
{
error(
- "The requester sent wrong sensorRearm count for the sensor, SENSOR_ID={SENSOR_ID} SENSOR_REARM_COUNT={SENSOR_REARM_CNT}",
- "SENSOR_ID", sensorId, "SENSOR_REARM_CNT",
- (uint16_t)sensorRearmCount);
+ "The requester sent wrong sensor rearm count '{SENSOR_REARM_COUNT}' for the sensor ID '{SENSORID}'.",
+ "SENSOR_REARM_COUNT", (uint16_t)sensorRearmCount, "SENSORID",
+ sensorId);
break;
}
@@ -942,9 +947,9 @@
if (compEffecterCnt > pdr->composite_effecter_count)
{
error(
- "The requester sent wrong composite effecter count for the effecter, EFFECTER_ID={EFFECTER_ID} COMP_EFF_CNT={COMP_EFF_CNT}",
- "EFFECTER_ID", effecterId, "COMP_EFF_CNT",
- (uint16_t)compEffecterCnt);
+ "The requester sent wrong composite effecter count '{COMPOSITE_EFFECTER_COUNT}' for the effecter ID '{EFFECTERID}'.",
+ "COMPOSITE_EFFECTER_COUNT", (uint16_t)compEffecterCnt,
+ "EFFECTERID", effecterId);
return false;
}
@@ -984,8 +989,9 @@
if (rc != PLDM_SUCCESS)
{
instanceIdDb->free(eid, instanceId);
- error("Failed to encode_set_event_receiver_req, rc = {RC}", "RC",
- lg2::hex, rc);
+ error(
+ "Failed to encode set event receiver request, response code '{RC}'",
+ "RC", lg2::hex, rc);
return;
}
@@ -1003,7 +1009,7 @@
if (rc || completionCode)
{
error(
- "Failed to decode setEventReceiver command response, rc = {RC}, cc = {CC}",
+ "Failed to decode setEventReceiver command, response code '{RC}' and completion code '{CC}'",
"RC", rc, "CC", (unsigned)completionCode);
pldm::utils::reportError(
"xyz.openbmc_project.bmc.pldm.InternalFailure");