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: If137ba802d0169fe6cd6c9ab8286d5f8cda31668
diff --git a/chassiskill.cpp b/chassiskill.cpp
index a209230..fa7ff68 100644
--- a/chassiskill.cpp
+++ b/chassiskill.cpp
@@ -1,13 +1,12 @@
 #include "utility.hpp"
 
 #include <nlohmann/json.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 
 #include <algorithm>
 #include <fstream>
 
 using json = nlohmann::json;
-using namespace phosphor::logging;
 using namespace utility;
 
 constexpr auto gpioDefsFile = "/etc/default/obmc/gpio/gpio_defs.json";
@@ -18,8 +17,8 @@
 
     if (!gpioDefsStream.is_open())
     {
-        log<level::ERR>("Error opening gpio definitions file",
-                        entry("FILE=%s", gpioDefsFile));
+        lg2::error("Error opening gpio definitions: {PATH}", "PATH",
+                   gpioDefsFile);
         return 1;
     }
 
@@ -27,8 +26,8 @@
 
     if (data.is_discarded())
     {
-        log<level::ERR>("Error parsing gpio definitions file",
-                        entry("FILE=%s", gpioDefsFile));
+        lg2::error("Error parsing gpio definitions: {PATH}", "PATH",
+                   gpioDefsFile);
         return 1;
     }
 
@@ -40,8 +39,8 @@
 
     if (gpios.size() <= 0)
     {
-        log<level::ERR>("Could not find power_up_outs defs",
-                        entry("FILE=%s", gpioDefsFile));
+        lg2::error("Could not find power_up_outs defs: {PATH}", "PATH",
+                   gpioDefsFile);
         return 1;
     }
 
@@ -61,14 +60,13 @@
 
             if (!gpioSetValue(pin, !activeLow, false))
             {
-                log<level::ERR>("chassiskill::gpioSetValue() failed",
-                                entry("PIN=%s", pin.c_str()));
+                lg2::error("chassiskill::gpioSetValue() failed: {PIN}", "PIN",
+                           pin);
                 return 1;
             }
             else
             {
-                log<level::INFO>("'chassiskill' operation complete",
-                                 entry("PIN=%s", pin.c_str()));
+                lg2::info("chassiskill::operation complete: {PIN}", "PIN", pin);
             }
         }
     }
diff --git a/utility.hpp b/utility.hpp
index 007ad37..89857fd 100644
--- a/utility.hpp
+++ b/utility.hpp
@@ -3,7 +3,7 @@
 #include <gpioplus/chip.hpp>
 #include <gpioplus/handle.hpp>
 #include <gpioplus/utility/aspeed.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 
 #include <exception>
 #include <string>
@@ -28,9 +28,7 @@
     }
     catch (const std::logic_error& e)
     {
-        phosphor::logging::log<phosphor::logging::level::ERR>(
-            "Error in gpioplus - nameToOffset",
-            phosphor::logging::entry("ERROR=%s", e.what()));
+        lg2::error("Error in gpioplus - nameToOffset: {ERROR}", "ERROR", e);
         return false;
     }
 
@@ -48,9 +46,7 @@
     }
     catch (const std::exception& e)
     {
-        phosphor::logging::log<phosphor::logging::level::ERR>(
-            "Error in gpioplus",
-            phosphor::logging::entry("ERROR=%s", e.what()));
+        lg2::error("Error in gpioplus: {ERROR}", "ERROR", e);
         return false;
     }