convert selutility.cpp to use lg2

Signed-off-by: George Liu <liuxiwei@ieisystem.com>
Change-Id: I22c54e0e1cfee99241ed50a4e0e224fbcc1442b6
diff --git a/selutility.cpp b/selutility.cpp
index c43a660..f868708 100644
--- a/selutility.cpp
+++ b/selutility.cpp
@@ -6,6 +6,7 @@
 #include <ipmid/types.hpp>
 #include <ipmid/utils.hpp>
 #include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/lg2.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 
 #include <charconv>
@@ -133,7 +134,7 @@
 {
     if (recordType != systemEventRecord)
     {
-        log<level::ERR>("Invalid recordType");
+        lg2::error("Invalid recordType");
         elog<InternalFailure>();
     }
 
@@ -198,8 +199,8 @@
     }
     catch (const std::exception& e)
     {
-        log<level::ERR>("Error in reading logging property entries",
-                        entry("ERROR=%s", e.what()));
+        lg2::error("Error in reading logging property entries: {ERROR}",
+                   "ERROR", e);
         elog<InternalFailure>();
     }
 
@@ -208,7 +209,7 @@
     auto iterId = entryData.find(propId);
     if (iterId == entryData.end())
     {
-        log<level::ERR>("Error in reading Id of logging entry");
+        lg2::error("Error in reading Id of logging entry");
         elog<InternalFailure>();
     }
 
@@ -217,7 +218,7 @@
     auto iterTimeStamp = entryData.find(propTimeStamp);
     if (iterTimeStamp == entryData.end())
     {
-        log<level::ERR>("Error in reading Timestamp of logging entry");
+        lg2::error("Error in reading Timestamp of logging entry");
         elog<InternalFailure>();
     }
     std::chrono::milliseconds chronoTimeStamp(
@@ -250,7 +251,7 @@
             // invSensor
             if (iter == invSensors.end())
             {
-                log<level::ERR>("System event sensor not found");
+                lg2::error("System event sensor not found");
                 elog<InternalFailure>();
             }
         }
@@ -288,7 +289,7 @@
         auto iterResolved = entryData.find(propResolved);
         if (iterResolved == entryData.end())
         {
-            log<level::ERR>("Error in reading Resolved field of logging entry");
+            lg2::error("Error in reading Resolved field of logging entry");
             elog<InternalFailure>();
         }
 
@@ -327,8 +328,8 @@
     }
     catch (const std::exception& e)
     {
-        log<level::ERR>("Error in reading Associations interface",
-                        entry("ERROR=%s", e.what()));
+        lg2::error("Error in reading Associations interface: {ERROR}", "ERROR",
+                   e);
         elog<InternalFailure>();
     }
 
@@ -347,7 +348,7 @@
                 iter = invSensors.find(BOARD_SENSOR);
                 if (iter == invSensors.end())
                 {
-                    log<level::ERR>("Motherboard sensor not found");
+                    lg2::error("Motherboard sensor not found");
                     elog<InternalFailure>();
                 }
             }
@@ -378,8 +379,8 @@
     }
     catch (const std::exception& e)
     {
-        log<level::ERR>("Error in reading Timestamp from Entry interface",
-                        entry("ERROR=%s", e.what()));
+        lg2::error("Error in reading Timestamp from Entry interface: {ERROR}",
+                   "ERROR", e);
         elog<InternalFailure>();
     }