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: I4aabaafe997e13c10d655a83a9ef0071ad11126e
diff --git a/command/session_cmds.cpp b/command/session_cmds.cpp
index 8a4014a..1405b6b 100644
--- a/command/session_cmds.cpp
+++ b/command/session_cmds.cpp
@@ -7,7 +7,7 @@
 
 #include <ipmid/sessionhelper.hpp>
 #include <ipmid/utils.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 
 #include <chrono>
 
@@ -15,7 +15,6 @@
 
 namespace command
 {
-using namespace phosphor::logging;
 
 std::vector<uint8_t>
     setSessionPrivilegeLevel(const std::vector<uint8_t>& inPayload,
@@ -119,10 +118,9 @@
     }
     catch (const std::exception& e)
     {
-        log<level::ERR>("Failed in getting session state property",
-                        entry("service=%s", service.c_str()),
-                        entry("object path=%s", obj.c_str()),
-                        entry("interface=%s", session::sessionIntf));
+        lg2::error(
+            "Failed in getting session state property: {SERVICE}, {PATH}, {INTERFACE}",
+            "SERVICE", service, "PATH", obj, "INTERFACE", session::sessionIntf);
         return ipmi::ccUnspecifiedError;
     }
 
@@ -170,9 +168,9 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>("Failed to fetch object from dbus",
-                        entry("INTERFACE=%s", session::sessionIntf),
-                        entry("ERRMSG=%s", e.what()));
+        lg2::error(
+            "Failed to fetch object from dbus, interface: {INTERFACE}, error: {ERROR}",
+            "INTERFACE", session::sessionIntf, "ERROR", e);
         return ipmi::ccUnspecifiedError;
     }
 
@@ -199,9 +197,9 @@
     }
     catch (const std::exception& e)
     {
-        log<level::ERR>("Failed to get session manager instance or sessionID "
-                        "by sessionHandle",
-                        entry("ERRMSG=%s", e.what()));
+        lg2::error(
+            "Failed to get session manager instance or sessionID by sessionHandle: {ERROR}",
+            "ERROR", e);
         return session::ccInvalidSessionHandle;
     }
 
@@ -218,8 +216,9 @@
     }
     catch (const std::exception& e)
     {
-        log<level::ERR>("Failed to get session manager instance or sessionID",
-                        entry("ERRMSG=%s", e.what()));
+        lg2::error(
+            "Failed to get session manager instance or sessionID: {ERROR}",
+            "ERROR", e);
         return session::ccInvalidSessionId;
     }
 
@@ -234,9 +233,9 @@
     }
     catch (const std::exception& e)
     {
-        log<level::ERR>(
-            "Failed to get session manager instance or stop session",
-            entry("ERRMSG=%s", e.what()));
+        lg2::error(
+            "Failed to get session manager instance or stop session: {ERROR}",
+            "ERROR", e);
         return ipmi::ccUnspecifiedError;
     }
 
@@ -300,9 +299,9 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>("Failed to fetch object from dbus",
-                        entry("INTERFACE=%s", session::sessionIntf),
-                        entry("ERRMSG=%s", e.what()));
+        lg2::error(
+            "Failed to fetch object from dbus, interface: {INTERFACE}, error: {ERROR}",
+            "INTERFACE", session::sessionIntf, "ERROR", e);
         response->completionCode = ipmi::ccUnspecifiedError;
         return outPayload;
     }