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.

Tested: built ledManager successfully and Unit Test passes.

Before: The file does not exist or is empty
After: The file does not exist or is empty, FILE_PATH = /usr/share/phosphor-led-manager/lamp-test-led-overrides.json

MESSAGE=File does not exist, FILE_PATH = /var/lib/phosphor-led-manager/savedGroups
LOG2_FMTMSG=File does not exist, FILE_PATH = {PATH}
CODE_FILE=../../../../../../fp5280g2-workspace/sources/phosphor-led-manager/serialize.cpp
CODE_LINE=63
CODE_FUNC=void phosphor::led::Serialize::restoreGroups()
PATH=/var/lib/phosphor-led-manager/savedGroups
SYSLOG_IDENTIFIER=phosphor-ledmanager
_PID=298
_COMM=phosphor-ledman
_EXE=/usr/bin/phosphor-ledmanager
_CMDLINE=phosphor-ledmanager
_SYSTEMD_CGROUP=/system.slice/xyz.openbmc_project.LED.GroupManager.service
_SYSTEMD_UNIT=xyz.openbmc_project.LED.GroupManager.service
_SYSTEMD_INVOCATION_ID=5ddd4960a3b04fe29c34e4ce03b6be06

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I5ec8530e0b539bcf8d7d211c802430698aebd343
diff --git a/lamptest.cpp b/lamptest.cpp
index 1182768..4c58e80 100644
--- a/lamptest.cpp
+++ b/lamptest.cpp
@@ -1,13 +1,12 @@
 #include "lamptest.hpp"
 
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 
 namespace phosphor
 {
 namespace led
 {
 
-using namespace phosphor::logging;
 using Json = nlohmann::json;
 
 bool LampTest::processLEDUpdates(const Manager::group& ledsAssert,
@@ -124,9 +123,9 @@
         auto name = object_path.filename();
         if (name.empty())
         {
-            log<level::ERR>(
-                "Failed to get the name of member of physical LED path",
-                entry("PATH=%s", path.c_str()), entry("NAME=%s", name.c_str()));
+            lg2::error(
+                "Failed to get the name of member of physical LED path, PATH = {PATH}, NAME = {NAME}",
+                "PATH", path, "NAME", name);
             continue;
         }
 
@@ -143,9 +142,9 @@
         }
         catch (const sdbusplus::exception::exception& e)
         {
-            log<level::ERR>("Failed to get All properties",
-                            entry("ERROR=%s", e.what()),
-                            entry("PATH=%s", path.c_str()));
+            lg2::error(
+                "Failed to get All properties, ERROR = {ERROR}, PATH = {PATH}",
+                "ERROR", e, "PATH", path);
             continue;
         }
 
@@ -203,7 +202,7 @@
     // set the Asserted property of lamp test to false
     if (!groupObj)
     {
-        log<level::ERR>("the Group object is nullptr");
+        lg2::error("the Group object is nullptr");
         throw std::runtime_error("the Group object is nullptr");
     }
 
@@ -254,9 +253,9 @@
     }
     catch (const sdbusplus::exception::exception& e)
     {
-        log<level::ERR>("Failed to set Asserted property",
-                        entry("ERROR=%s", e.what()),
-                        entry("PATH=%s", HOST_LAMP_TEST_OBJECT));
+        lg2::error(
+            "Failed to set Asserted property, ERROR = {ERROR}, PATH = {PATH}",
+            "ERROR", e, "PATH", std::string(HOST_LAMP_TEST_OBJECT));
     }
 }
 
@@ -264,8 +263,8 @@
 {
     if (!fs::exists(path) || fs::is_empty(path))
     {
-        log<level::INFO>("The file does not exist or is empty",
-                         entry("FILE_PATH=%s", path.c_str()));
+        lg2::info("The file does not exist or is empty, FILE_PATH = {PATH}",
+                  "PATH", path);
         return;
     }
 
@@ -290,9 +289,9 @@
     }
     catch (const std::exception& e)
     {
-        log<level::ERR>("Failed to parse config file",
-                        entry("ERROR=%s", e.what()),
-                        entry("FILE_PATH=%s", path.c_str()));
+        lg2::error(
+            "Failed to parse config file, ERROR = {ERROR}, FILE_PATH = {PATH}",
+            "ERROR", e, "PATH", path);
     }
     return;
 }