use phosphor-logging
Migrate all instances of std::cerr and std::cout to phosphor-logging
such as lg2::error, lg2::info, lg2::debug, ...
The use of modern logging infrastructure helps with development since
additional logging levels such as `debug` and `warning` are available.
Migrating the remaining logging calls helps to make the code more
readable and uniform.
Tested: Inspection, and on Tyan S8030
Restarted EM with patch applied.
Logs appear as usual.
```
Sep 15 13:52:46 s8030-bmc-30303035c0c1 entity-manager[23480]: Inventory Added: Supermicro PWS 920P SQ 0
Sep 15 13:52:46 s8030-bmc-30303035c0c1 entity-manager[23480]: Inventory Added: Supermicro PWS 920P SQ 1
Sep 15 13:52:46 s8030-bmc-30303035c0c1 entity-manager[23480]: Inventory Added: Tyan S8030 Baseboard
Sep 15 13:52:46 s8030-bmc-30303035c0c1 entity-manager[23480]: Inventory Added: MBX 1.57 Chassis
```
`busctl tree` output appears as before.
Did a power cycle to trigger a few more log prints
```
Sep 15 13:55:14 s8030-bmc-30303035c0c1 entity-manager[23480]: power match triggered
```
Created configuration file with missing fields to trigger error print.
```
{
  "Exposes": [],
  "Type": "error"
}
```
```
Sep 15 13:56:58 s8030-bmc-30303035c0c1 entity-manager[23659]: Finished loading json configuration in 7938ms
Sep 15 13:56:58 s8030-bmc-30303035c0c1 entity-manager[23659]: configuration file missing probe:
                                                               {"Exposes":[],"Type":"error"}
Sep 15 13:56:59 s8030-bmc-30303035c0c1 entity-manager[23659]: configuration file missing probe:
                                                               {"Exposes":[],"Type":"error"}
```
Change-Id: I3452f983c9c14cd02ab9b56451c4b3e4a13c3979
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/src/entity_manager/entity_manager.cpp b/src/entity_manager/entity_manager.cpp
index 22f9a6a..ef4212a 100644
--- a/src/entity_manager/entity_manager.cpp
+++ b/src/entity_manager/entity_manager.cpp
@@ -10,7 +10,6 @@
 #include "log_device_inventory.hpp"
 #include "overlay.hpp"
 #include "perform_scan.hpp"
-#include "phosphor-logging/lg2.hpp"
 #include "topology.hpp"
 #include "utils.hpp"
 
@@ -25,13 +24,13 @@
 #include <boost/container/flat_set.hpp>
 #include <boost/range/iterator_range.hpp>
 #include <nlohmann/json.hpp>
+#include <phosphor-logging/lg2.hpp>
 #include <sdbusplus/asio/connection.hpp>
 #include <sdbusplus/asio/object_server.hpp>
 
 #include <filesystem>
 #include <fstream>
 #include <functional>
-#include <iostream>
 #include <map>
 #include <regex>
 constexpr const char* tempConfigDir = "/tmp/configuration/";
@@ -126,8 +125,8 @@
     }
     else
     {
-        std::cerr << "Unable to find type for " << boardName
-                  << " reverting to Chassis.\n";
+        lg2::error("Unable to find type for {BOARD} reverting to Chassis.",
+                   "BOARD", boardName);
         boardType = "Chassis";
     }
 
@@ -198,7 +197,7 @@
     auto findName = item.find("Name");
     if (findName == item.end())
     {
-        std::cerr << "cannot find name in field " << item << "\n";
+        lg2::error("cannot find name in field {ITEM}", "ITEM", item);
         return;
     }
     auto findStatus = item.find("Status");
@@ -318,7 +317,7 @@
         }
         if (!isLegal)
         {
-            std::cerr << "dbus format error" << config << "\n";
+            lg2::error("dbus format error {JSON}", "JSON", config);
             return false;
         }
 
@@ -458,7 +457,7 @@
     boost::asio::post(io, [this]() {
         if (!writeJsonFiles(systemConfiguration))
         {
-            std::cerr << "Error writing json files\n";
+            lg2::error("Error writing json files");
         }
     });
 
@@ -489,7 +488,7 @@
             }
             if (ec)
             {
-                std::cerr << "async wait error " << ec << "\n";
+                lg2::error("async wait error {ERR}", "ERR", ec.message());
                 return;
             }
 
@@ -582,8 +581,8 @@
                 auto data = nlohmann::json::parse(jsonStream, nullptr, false);
                 if (data.is_discarded())
                 {
-                    std::cerr
-                        << "syntax error in " << lastConfiguration << "\n";
+                    lg2::error("syntax error in {PATH}", "PATH",
+                               lastConfiguration);
                 }
                 else
                 {
@@ -592,7 +591,7 @@
             }
             else
             {
-                std::cerr << "unable to open " << lastConfiguration << "\n";
+                lg2::error("unable to open {PATH}", "PATH", lastConfiguration);
             }
         }
     }
@@ -600,7 +599,7 @@
     {
         // not an error, just logging at this level to make it in the journal
         std::error_code ec;
-        std::cerr << "Clearing previous configuration\n";
+        lg2::error("Clearing previous configuration");
         std::filesystem::remove(currentConfiguration, ec);
     }
 }