src: Convert logging to lg2

Change-Id: I28bf669e5139062f0f6145277db65d6821d48e78
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
diff --git a/src/DeviceMgmt.hpp b/src/DeviceMgmt.hpp
index 5247486..09644ab 100644
--- a/src/DeviceMgmt.hpp
+++ b/src/DeviceMgmt.hpp
@@ -6,6 +6,7 @@
 
 #include <boost/algorithm/string/replace.hpp>
 #include <boost/container/flat_map.hpp>
+#include <phosphor-logging/lg2.hpp>
 #include <sdbusplus/asio/connection.hpp>
 #include <sdbusplus/bus/match.hpp>
 #include <sdbusplus/message.hpp>
@@ -13,7 +14,6 @@
 #include <cstddef>
 #include <cstdint>
 #include <functional>
-#include <iostream>
 #include <memory>
 #include <optional>
 #include <stdexcept>
@@ -120,8 +120,8 @@
                 std::get_if<std::string>(&findSensorName->second);
             if (sensorName == nullptr)
             {
-                std::cerr << "Unable to find sensor name " << name
-                          << " on path " << path.str << "\n";
+                lg2::info("Unable to find '{NAME}' on '{PATH}'", "NAME", name,
+                          "PATH", path.str);
                 continue;
             }
 
@@ -157,8 +157,8 @@
                 // ensure that we end up with a fresh instance of it.
                 if (params->devicePresent())
                 {
-                    std::cerr << "Clearing out previous instance for "
-                              << path.str << "\n";
+                    lg2::info("Clearing out previous instance for '{PATH}'",
+                              "PATH", path.str);
                     I2CDevice tmp(*params);
                 }
 
@@ -171,9 +171,10 @@
                 }
                 catch (std::runtime_error&)
                 {
-                    std::cerr << "Failed to instantiate " << params->type->name
-                              << " at address " << params->address << " on bus "
-                              << params->bus << "\n";
+                    lg2::error(
+                        "Failed to instantiate '{NAME}' at address '{ADDR}' on bus '{BUS}'",
+                        "NAME", params->type->name, "ADDR", params->address,
+                        "BUS", params->bus);
                 }
             }
         }