logging: switch to lg2

After switching to C++20, it is recommended to use `phosphor::lg2`
to format log, and the correct `CODE_LINE` and `CODE_FUNC` values
can be used in log tracking.

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: If1cbc1f1eb4ccd02fe2e95f2f09a4fd0b43a0851
diff --git a/association_manager.cpp b/association_manager.cpp
index c376718..ade689d 100644
--- a/association_manager.cpp
+++ b/association_manager.cpp
@@ -1,6 +1,6 @@
 #include "association_manager.hpp"
 
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 
 #include <filesystem>
 #include <fstream>
@@ -13,7 +13,6 @@
 {
 namespace associations
 {
-using namespace phosphor::logging;
 namespace fs = std::filesystem;
 
 Manager::Manager(sdbusplus::bus::bus& bus, const std::string& jsonPath) :
@@ -66,10 +65,9 @@
                     !conditionJSON.contains("property") ||
                     !conditionJSON.contains("values"))
                 {
-                    std::string msg =
-                        "Invalid JSON in associations condition entry in " +
-                        path.string() + ". Skipping file.";
-                    log<level::ERR>(msg.c_str());
+                    lg2::error(
+                        "Invalid JSON in associations condition entry in {PATH}. Skipping file.",
+                        "PATH", path);
                     continue;
                 }
 
@@ -117,11 +115,11 @@
                     }
                     else
                     {
-                        std::stringstream ss;
-                        ss << "Invalid condition property value in " << c.file
-                           << ": " << value;
-                        log<level::ERR>(ss.str().c_str());
-                        throw std::runtime_error(ss.str());
+                        lg2::error(
+                            "Invalid condition property value in {FILE}:",
+                            "FILE", c.file);
+                        throw std::runtime_error(
+                            "Invalid condition property value");
                     }
                 }
 
diff --git a/errors.cpp b/errors.cpp
index b751107..3712185 100644
--- a/errors.cpp
+++ b/errors.cpp
@@ -15,7 +15,7 @@
  */
 #include "errors.hpp"
 
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 
 namespace phosphor
 {
@@ -25,8 +25,7 @@
 {
 void InterfaceError::log() const
 {
-    logging::log<logging::level::ERR>(
-        what(), phosphor::logging::entry("INTERFACE=%s", interface.c_str()));
+    lg2::error("{INTF} unrecognized", "INTF", interface);
 }
 } // namespace manager
 } // namespace inventory
diff --git a/manager.cpp b/manager.cpp
index c5797cc..fad77e6 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -17,8 +17,6 @@
 
 #include "errors.hpp"
 
-#include <phosphor-logging/log.hpp>
-
 #include <algorithm>
 #include <chrono>
 #include <exception>
diff --git a/serialize.hpp b/serialize.hpp
index 4bae397..ace13c4 100644
--- a/serialize.hpp
+++ b/serialize.hpp
@@ -3,7 +3,7 @@
 #include "config.h"
 
 #include <cereal/archives/json.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 
 #include <filesystem>
 #include <fstream>
@@ -88,7 +88,7 @@
         }
         catch (const cereal::Exception& e)
         {
-            phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
+            lg2::error("Deserialization failed: {ERROR}", "ERROR", e);
             fs::remove(p);
         }
     }