convert storagehandler.cpp to use lg2

Signed-off-by: George Liu <liuxiwei@ieisystem.com>
Change-Id: I73d2f8db22aa1444998d04749f9e31104faa3677
diff --git a/storagehandler.cpp b/storagehandler.cpp
index 18aba33..f90de63 100644
--- a/storagehandler.cpp
+++ b/storagehandler.cpp
@@ -16,7 +16,7 @@
 #include <ipmid/utils.hpp>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 #include <sdbusplus/server.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 #include <xyz/openbmc_project/Logging/SEL/error.hpp>
@@ -120,7 +120,7 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>("Failed to read object path");
+        lg2::error("Failed to read object path");
         return;
     }
     std::string p = objPath;
@@ -140,7 +140,7 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>("Failed to read object path");
+        lg2::error("Failed to read object path");
     }
     try
     {
@@ -149,7 +149,7 @@
     }
     catch (const std::invalid_argument& e)
     {
-        log<level::ERR>("Invalid logging entry ID");
+        lg2::error("Invalid logging entry ID");
     }
 }
 
@@ -200,7 +200,7 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>("Failed to get logging object paths");
+        lg2::error("Failed to get logging object paths");
         return;
     }
     for (const auto& p : paths)
@@ -271,7 +271,7 @@
         {}
         catch (const std::runtime_error& e)
         {
-            log<level::ERR>(e.what());
+            lg2::error("runtime error: {ERROR}", "ERROR", e);
         }
     }
 
@@ -461,7 +461,7 @@
     }
     catch (const std::runtime_error& e)
     {
-        log<level::ERR>(e.what());
+        lg2::error("runtime error: {ERROR}", "ERROR", e);
         return ipmi::responseUnspecifiedError();
     }
 
@@ -535,7 +535,7 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>("Error eraseAll ", entry("ERROR=%s", e.what()));
+        lg2::error("Error eraseAll: {ERROR}", "ERROR", e);
         return ipmi::responseUnspecifiedError();
     }
 
@@ -564,18 +564,17 @@
     }
     catch (const InternalFailure& e)
     {
-        log<level::ERR>(e.what());
+        lg2::error("Internal Failure: {ERROR}", "ERROR", e);
         return ipmi::responseUnspecifiedError();
     }
     catch (const std::exception& e)
     {
-        log<level::ERR>(e.what());
+        lg2::error("exception message: {ERROR}", "ERROR", e);
         return ipmi::responseUnspecifiedError();
     }
 
-    bmcTime << "BMC time:"
-            << duration_cast<seconds>(microseconds(bmc_time_usec)).count();
-    log<level::DEBUG>(bmcTime.str().c_str());
+    lg2::debug("BMC time: {BMC_TIME}", "BMC_TIME",
+               duration_cast<seconds>(microseconds(bmc_time_usec)).count());
 
     // Time is really long int but IPMI wants just uint32. This works okay until
     // the number of seconds since 1970 overflows uint32 size.. Still a whole
@@ -617,12 +616,12 @@
     }
     catch (const InternalFailure& e)
     {
-        log<level::ERR>(e.what());
+        lg2::error("Internal Failure: {ERROR}", "ERROR", e);
         return ipmi::responseUnspecifiedError();
     }
     catch (const std::exception& e)
     {
-        log<level::ERR>(e.what());
+        lg2::error("exception message: {ERROR}", "ERROR", e);
         return ipmi::responseUnspecifiedError();
     }
 
@@ -786,7 +785,7 @@
     }
     catch (const InternalFailure& e)
     {
-        log<level::ERR>(e.what());
+        lg2::error("Internal Failure: {ERROR}", "ERROR", e);
         return ipmi::responseUnspecifiedError();
     }
 }
@@ -844,7 +843,7 @@
     }
     catch (const InternalFailure& e)
     {
-        log<level::ERR>(e.what());
+        lg2::error("Internal Failure: {ERROR}", "ERROR", e);
         return ipmi::responseUnspecifiedError();
     }
 }