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/libpldmresponder/pdr_state_sensor.hpp b/libpldmresponder/pdr_state_sensor.hpp
index 6effc53..838f6e7 100644
--- a/libpldmresponder/pdr_state_sensor.hpp
+++ b/libpldmresponder/pdr_state_sensor.hpp
@@ -4,6 +4,10 @@
 
 #include <libpldm/platform.h>
 
+#include <phosphor-logging/lg2.hpp>
+
+PHOSPHOR_LOG2_USING;
+
 namespace pldm
 {
 namespace responder
@@ -37,10 +41,10 @@
             auto statesSize = set.value("size", 0);
             if (!statesSize)
             {
-                std::cerr << "Malformed PDR JSON return "
-                             "pdrEntry;- no state set "
-                             "info, TYPE="
-                          << PLDM_STATE_SENSOR_PDR << "\n";
+                error(
+                    "Malformed PDR JSON return pdrEntry;- no state set info, TYPE={STATE_SENSOR_PDR}",
+                    "STATE_SENSOR_PDR",
+                    static_cast<int>(PLDM_STATE_SENSOR_PDR));
                 throw InternalFailure();
             }
             pdrSize += sizeof(state_sensor_possible_states) -
@@ -55,7 +59,7 @@
             reinterpret_cast<pldm_state_sensor_pdr*>(entry.data());
         if (!pdr)
         {
-            std::cerr << "Failed to get state sensor PDR.\n";
+            error("Failed to get state sensor PDR.");
             continue;
         }
         pdr->hdr.record_handle = 0;
@@ -169,8 +173,9 @@
             }
             catch (const std::exception& e)
             {
-                std::cerr << "D-Bus object path does not exist, sensor ID: "
-                          << pdr->sensor_id << "\n";
+                error(
+                    "D-Bus object path does not exist, sensor ID: {SENSOR_ID}",
+                    "SENSOR_ID", static_cast<uint16_t>(pdr->sensor_id));
             }
 
             dbusMappings.emplace_back(std::move(dbusMapping));