pldmd, requester, softoff & utilities: 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: I230e9e1404db8c92c81e2f872183d691c91ff16c
Signed-off-by: Riya Dixit <riyadixitagra@gmail.com>
diff --git a/softoff/softoff.cpp b/softoff/softoff.cpp
index df5807e..c522635 100644
--- a/softoff/softoff.cpp
+++ b/softoff/softoff.cpp
@@ -46,7 +46,7 @@
 
     if (jsonData.is_discarded())
     {
-        error("Parsing softoff config JSON file failed");
+        error("Failed to parse softoff config JSON file");
         return;
     }
 
@@ -69,8 +69,8 @@
             auto rc = getSensorInfo(entityType, stateSetId);
             if (rc != PLDM_SUCCESS)
             {
-                error("Message get Sensor PDRs error. PLDM error code = {RC}",
-                      "RC", lg2::hex, static_cast<int>(rc));
+                error("Failed to get Sensor PDRs, response code '{RC}'", "RC",
+                      lg2::hex, static_cast<int>(rc));
                 hasError = true;
                 return;
             }
@@ -113,8 +113,9 @@
     }
     catch (const std::exception& e)
     {
-        error("PLDM host soft off: Can't get current host state: {ERROR}",
-              "ERROR", e);
+        error(
+            "PLDM remote terminus soft off. Can't get current remote terminus state, error - {ERROR}",
+            "ERROR", e);
         hasError = true;
         return PLDM_ERROR;
     }
@@ -141,8 +142,9 @@
         auto rc = timer.stop();
         if (rc < 0)
         {
-            error("PLDM soft off: Failure to STOP the timer. ERRNO={RC}", "RC",
-                  rc);
+            error(
+                "Failure to STOP the timer of PLDM soft off, response code '{RC}'",
+                "RC", rc);
         }
 
         // This marks the completion of pldm soft power off.
@@ -157,7 +159,9 @@
 
     if (!fs::exists(softoffConfigJson) || fs::is_empty(softoffConfigJson))
     {
-        error("Parsing softoff config JSON file failed, File does not exist");
+        error(
+            "Failed to parse softoff config JSON file '{PATH}', file does not exist",
+            "PATH", softoffConfigJson);
         return PLDM_ERROR;
     }
 
@@ -195,8 +199,7 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        error("PLDM soft off: Error get softPowerOff PDR,ERROR={ERR_EXCEP}",
-              "ERR_EXCEP", e.what());
+        error("Failed to get softPowerOff PDR, error - {ERROR}", "ERROR", e);
         return false;
     }
     return true;
@@ -259,8 +262,8 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        error("PLDM soft off: Error get State Sensor PDR,ERROR={ERR_EXCEP}",
-              "ERR_EXCEP", e.what());
+        error("Failed to get state sensor PDR during soft-off, error - {ERROR}",
+              "ERROR", e);
         return PLDM_ERROR;
     }
 
@@ -291,8 +294,9 @@
     if (rc != PLDM_SUCCESS)
     {
         instanceIdDb.free(pldmTID, instanceID);
-        error("Message encode failure. PLDM error code = {RC}", "RC", lg2::hex,
-              static_cast<int>(rc));
+        error(
+            "Failed to encode set state effecter states request message, response code '{RC}'",
+            "RC", lg2::hex, static_cast<int>(rc));
         return PLDM_ERROR;
     }
 
@@ -303,7 +307,7 @@
         {
             instanceIdDb.free(pldmTID, instanceID);
             error(
-                "PLDM soft off: ERROR! Can't get the response for the PLDM request msg. Time out! Exit the pldm-softpoweroff");
+                "PLDM soft off failed, can't get the response for the PLDM request msg. Time out! Exit the pldm-softpoweroff");
             exit(-1);
         }
         return;
@@ -331,8 +335,9 @@
         auto rc = pldmTransport.recvMsg(pldmTID, responseMsg, responseMsgSize);
         if (rc)
         {
-            error("Soft off: failed to recv pldm data. PLDM RC = {RC}", "RC",
-                  static_cast<int>(rc));
+            error(
+                "Failed to receive pldm data during soft-off, response code '{RC}'",
+                "RC", static_cast<int>(rc));
             return;
         }
 
@@ -357,7 +362,7 @@
 
         if (response->payload[0] != PLDM_SUCCESS)
         {
-            error("Getting the wrong response. PLDM RC = {RC}", "RC",
+            error("Getting the wrong response, response code '{RC}'", "RC",
                   (unsigned)response->payload[0]);
             exit(-1);
         }
@@ -373,14 +378,14 @@
         if (ret < 0)
         {
             error(
-                "Failure to start Host soft off wait timer, ERRNO = {RET}. Exit the pldm-softpoweroff",
-                "RET", ret);
+                "Failure to start remote terminus soft off wait timer, Exit the pldm-softpoweroff with response code:{NUM}",
+                "NUM", ret);
             exit(-1);
         }
         else
         {
             error(
-                "Timer started waiting for host soft off, TIMEOUT_IN_SEC = {TIMEOUT_SEC}",
+                "Timer started waiting for remote terminus soft off, timeout in sec '{TIMEOUT_SEC}'",
                 "TIMEOUT_SEC", SOFTOFF_TIMEOUT_SECONDS);
         }
         return;
@@ -393,8 +398,8 @@
     {
         instanceIdDb.free(pldmTID, instanceID);
         error(
-            "Failed to send message/receive response. RC = {RC}, errno = {ERR}",
-            "RC", static_cast<int>(rc), "ERR", errno);
+            "Failed to send message/receive response, response code '{RC}' and error - {ERROR}",
+            "RC", static_cast<int>(rc), "ERROR", errno);
         return PLDM_ERROR;
     }
 
@@ -409,8 +414,8 @@
         {
             instanceIdDb.free(pldmTID, instanceID);
             error(
-                "PLDM host soft off: Failure in processing request.ERROR= {ERR_EXCEP}",
-                "ERR_EXCEP", e.what());
+                "Failed to process request while remote terminus soft off, error - {ERROR}",
+                "ERROR", e);
             return PLDM_ERROR;
         }
     }