oem-ibm: 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: I24ca21de35d5a1a9b3cc64b28a149e4c213055f9
Signed-off-by: Riya Dixit <riyadixitagra@gmail.com>
diff --git a/oem/ibm/libpldmresponder/oem_ibm_handler.cpp b/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
index 8e207be..906e964 100644
--- a/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
+++ b/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
@@ -167,7 +167,7 @@
reinterpret_cast<pldm_state_effecter_pdr*>(entry.data());
if (!pdr)
{
- error("Failed to get record by PDR type, ERROR:{ERR_CODE}", "ERR_CODE",
+ error("Failed to get record by PDR type, error - {ERROR}", "ERROR",
lg2::hex,
static_cast<unsigned>(PLDM_PLATFORM_INVALID_EFFECTER_ID));
return;
@@ -219,7 +219,7 @@
reinterpret_cast<pldm_state_sensor_pdr*>(entry.data());
if (!pdr)
{
- error("Failed to get record by PDR type, ERROR:{ERR_CODE}", "ERR_CODE",
+ error("Failed to get record by PDR type, error - {ERROR}", "ERROR",
lg2::hex, static_cast<unsigned>(PLDM_PLATFORM_INVALID_SENSOR_ID));
return;
}
@@ -321,7 +321,7 @@
if (rc || completionCode)
{
error(
- "Failed to decode_platform_event_message_resp: for code update event rc={RC}, cc={CC}",
+ "Failed to decode platform event message response for code update event with response code '{RC}' and completion code '{CC}'",
"RC", rc, "CC", static_cast<unsigned>(completionCode));
}
};
@@ -376,14 +376,17 @@
instanceId);
if (rc != PLDM_SUCCESS)
{
- error("Failed to encode state sensor event, rc = {RC}", "RC", rc);
+ error("Failed to encode state sensor event with response code '{RC}'",
+ "RC", rc);
instanceIdDb.free(mctp_eid, instanceId);
return;
}
rc = sendEventToHost(requestMsg, instanceId);
if (rc != PLDM_SUCCESS)
{
- error("Failed to send event to host: rc={RC}", "RC", rc);
+ error(
+ "Failed to send event to remote terminus with response code '{RC}'",
+ "RC", rc);
}
return;
}
@@ -464,8 +467,8 @@
catch (const std::exception& e)
{
error(
- "Chassis State transition to Off failed, unable to set property RequestedPowerTransition ERROR={ERR_EXCEP}",
- "ERR_EXCEP", e.what());
+ "Failure in chassis State transition to Off, unable to set property RequestedPowerTransition, error - {ERROR}",
+ "ERROR", e);
}
using namespace sdbusplus::bus::match::rules;
@@ -498,8 +501,8 @@
catch (const std::exception& e)
{
error(
- "Setting one-time restore policy failed, unable to set property PowerRestorePolicy ERROR={ERR_EXCEP}",
- "ERR_EXCEP", e.what());
+ "Failure in setting one-time restore policy, unable to set property PowerRestorePolicy, error - {ERROR}",
+ "ERROR", e);
}
dbusMapping = pldm::utils::DBusMapping{
"/xyz/openbmc_project/state/bmc0",
@@ -513,8 +516,8 @@
catch (const std::exception& e)
{
error(
- "BMC state transition to reboot failed, unable to set property RequestedBMCTransition ERROR={ERR_EXCEP}",
- "ERR_EXCEP", e.what());
+ "Failure in BMC state transition to reboot, unable to set property RequestedBMCTransition , error - {ERROR}",
+ "ERROR", e);
}
}
}
@@ -576,8 +579,7 @@
}
catch (const std::exception& e)
{
- error("Failed To reset watchdog timer ERROR={ERR_EXCEP}", "ERR_EXCEP",
- e.what());
+ error("Failed to reset watchdog timer, error - {ERROR}", "ERROR", e);
return;
}
}
@@ -600,8 +602,7 @@
}
catch (const std::exception& e)
{
- error("Failed To disable watchdog timer ERROR={ERR_EXCEP}", "ERR_EXCEP",
- e.what());
+ error("Failed to disable watchdog timer, error - {ERROR}", "ERROR", e);
}
}
int pldm::responder::oem_ibm_platform::Handler::checkBMCState()
@@ -624,7 +625,8 @@
}
catch (const std::exception& e)
{
- error("Error getting the current BMC state: {ERROR}", "ERROR", e);
+ error("Error getting the current BMC state, error - {ERROR}", "ERROR",
+ e);
return PLDM_ERROR;
}
return PLDM_SUCCESS;