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/bios_table.cpp b/libpldmresponder/bios_table.cpp
index 1b28a53..b264ea7 100644
--- a/libpldmresponder/bios_table.cpp
+++ b/libpldmresponder/bios_table.cpp
@@ -8,6 +8,8 @@
 
 #include <fstream>
 
+PHOSPHOR_LOG2_USING;
+
 namespace pldm
 {
 namespace responder
@@ -156,8 +158,8 @@
         table.data() + tableSize, entryLength, info);
     if (rc != PLDM_SUCCESS)
     {
-        lg2::error("Failed to encode BIOS table string entry: {LIBPLDM_ERROR}",
-                   "LIBPLDM_ERROR", rc);
+        error("Failed to encode BIOS table string entry, response code '{RC}'",
+              "RC", rc);
         throw std::runtime_error("Failed to encode BIOS table string entry");
     }
     return reinterpret_cast<pldm_bios_attr_table_entry*>(table.data() +
@@ -175,9 +177,9 @@
         table.data() + tableSize, entryLength, info);
     if (rc != PLDM_SUCCESS)
     {
-        lg2::error(
-            "Failed to encode BIOS attribute table integer entry: {LIBPLDM_ERROR}",
-            "LIBPLDM_ERROR", rc);
+        error(
+            "Failed to encode BIOS attribute table integer entry, response code '{RC}'",
+            "RC", rc);
         throw std::runtime_error(
             "Failed to encode BIOS attribute table integer entry");
     }
@@ -195,9 +197,9 @@
         entry, &defLength);
     if (rc != PLDM_SUCCESS)
     {
-        lg2::error(
-            "Failed to decode BIOS table string definition length: {LIBPLDM_ERROR}",
-            "LIBPLDM_ERROR", rc);
+        error(
+            "Failed to decode BIOS table string definition length, response code '{RC}'",
+            "RC", rc);
         throw std::runtime_error(
             "Failed to decode BIOS table string definitionlength");
     }
@@ -241,9 +243,9 @@
     int rc = pldm_bios_table_attr_entry_enum_decode_pv_num_check(entry, &pvNum);
     if (rc != PLDM_SUCCESS)
     {
-        lg2::error(
-            "Failed to decode the number of possible values for BIOS table enum entry: {LIBPLDM_ERROR}",
-            "LIBPLDM_ERROR", rc);
+        error(
+            "Failed to decode the number of possible values for BIOS table enum entry, response code '{RC}'",
+            "RC", rc);
         throw std::runtime_error(
             "Failed to decode the number of possible values for BIOS table enum entry");
     }
@@ -310,9 +312,9 @@
         str.c_str());
     if (rc != PLDM_SUCCESS)
     {
-        lg2::error(
-            "Failed to encode BIOS attribute table string entry: {LIBPLDM_ERROR}",
-            "LIBPLDM_ERROR", rc);
+        error(
+            "Failed to encode BIOS attribute table string entry, response code '{RC}'",
+            "RC", rc);
         throw std::runtime_error(
             "Failed to encode BIOS attribute table string entry");
     }
@@ -333,9 +335,9 @@
         table.data() + tableSize, entryLength, attrHandle, attrType, value);
     if (rc != PLDM_SUCCESS)
     {
-        lg2::error(
-            "Failed to encode BIOS attribute table integer entry: {LIBPLDM_ERROR}",
-            "LIBPLDM_ERROR", rc);
+        error(
+            "Failed to encode BIOS attribute table integer entry, response code '{RC}'",
+            "RC", rc);
         throw std::runtime_error(
             "Failed to encode BIOS attribute table integery entry");
     }
@@ -356,9 +358,9 @@
         handleIndices.size(), handleIndices.data());
     if (rc != PLDM_SUCCESS)
     {
-        lg2::error(
-            "Failed to encode BIOS attribute table enum entry: {LIBPLDM_ERROR}",
-            "LIBPLDM_ERROR", rc);
+        error(
+            "Failed to encode BIOS attribute table enum entry, response code '{RC}'",
+            "RC", rc);
         throw std::runtime_error(
             "Failed to encode BIOS attribute table enum entry");
     }