app: switch to lg2

Signed-off-by: George Liu <liuxiwei@ieisystem.com>
Change-Id: Id55c91667a7bd0184ec4d55d6e1c15844d9ffb50
diff --git a/app/channel.cpp b/app/channel.cpp
index c22bd8d..a1e42fa 100644
--- a/app/channel.cpp
+++ b/app/channel.cpp
@@ -8,7 +8,7 @@
 #include <ipmid/types.hpp>
 #include <ipmid/utils.hpp>
 #include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 
 #include <fstream>
@@ -43,14 +43,14 @@
     std::ifstream jsonFile(configFile);
     if (!jsonFile.is_open())
     {
-        log<level::ERR>("Channel Cipher suites file not found");
+        lg2::error("Channel Cipher suites file not found");
         elog<InternalFailure>();
     }
 
     auto data = Json::parse(jsonFile, nullptr, false);
     if (data.is_discarded())
     {
-        log<level::ERR>("Parsing channel cipher suites JSON failed");
+        lg2::error("Parsing channel cipher suites JSON failed");
         elog<InternalFailure>();
     }
 
@@ -131,7 +131,7 @@
     }
     if (!ipmi::isValidPayloadType(static_cast<ipmi::PayloadType>(payloadType)))
     {
-        log<level::DEBUG>("Get channel cipher suites - Invalid payload type");
+        lg2::debug("Get channel cipher suites - Invalid payload type");
         constexpr uint8_t ccPayloadTypeNotSupported = 0x80;
         return ipmi::response(ccPayloadTypeNotSupported);
     }
@@ -159,7 +159,7 @@
          ipmi::EChannelSessSupported::none) ||
         !(ipmi::doesDeviceExist(rspChannel)))
     {
-        log<level::DEBUG>("Get channel cipher suites - Device does not exist");
+        lg2::debug("Get channel cipher suites - Device does not exist");
         return ipmi::responseInvalidFieldRequest();
     }
 
diff --git a/app/watchdog.cpp b/app/watchdog.cpp
index e64cb72..dd65e45 100644
--- a/app/watchdog.cpp
+++ b/app/watchdog.cpp
@@ -7,7 +7,7 @@
 #include <ipmid/api.hpp>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 
 #include <bitset>
@@ -68,13 +68,12 @@
     }
     catch (const std::exception& e)
     {
-        const std::string e_str = std::string("wd_reset: ") + e.what();
-        log<level::ERR>(e_str.c_str());
+        lg2::error("wd_reset: {ERROR}", "ERROR", e);
         return ipmi::responseUnspecifiedError();
     }
     catch (...)
     {
-        log<level::ERR>("wd_reset: Unknown Error");
+        lg2::error("wd_reset: Unknown Error");
         return ipmi::responseUnspecifiedError();
     }
 }
@@ -265,13 +264,12 @@
     }
     catch (const std::exception& e)
     {
-        const std::string e_str = std::string("wd_set: ") + e.what();
-        log<level::ERR>(e_str.c_str());
+        lg2::error("wd_set: {ERROR}", "ERROR", e);
         return ipmi::responseUnspecifiedError();
     }
     catch (...)
     {
-        log<level::ERR>("wd_set: Unknown Error");
+        lg2::error("wd_set: Unknown Error");
         return ipmi::responseUnspecifiedError();
     }
 }
@@ -431,13 +429,12 @@
     }
     catch (const std::exception& e)
     {
-        const std::string e_str = std::string("wd_get: ") + e.what();
-        log<level::ERR>(e_str.c_str());
+        lg2::error("wd_get: {ERROR}", "ERROR", e);
         return ipmi::responseUnspecifiedError();
     }
     catch (...)
     {
-        log<level::ERR>("wd_get: Unknown Error");
+        lg2::error("wd_get: Unknown Error");
         return ipmi::responseUnspecifiedError();
     }
 }
diff --git a/app/watchdog_service.cpp b/app/watchdog_service.cpp
index 7ba0932..b67b5c7 100644
--- a/app/watchdog_service.cpp
+++ b/app/watchdog_service.cpp
@@ -3,7 +3,7 @@
 #include <ipmid/api.hpp>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/message.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
@@ -46,10 +46,9 @@
             // Retry the request once in case the cached service was stale
             return resetTimeRemaining(enableWatchdog);
         }
-        log<level::ERR>(
-            "WatchdogService: Method error resetting time remaining",
-            entry("ENABLE_WATCHDOG=%d", !!enableWatchdog),
-            entry("ERROR=%s", e.what()));
+        lg2::error("WatchdogService: Method error resetting time remaining, "
+                   "ENABLE_WATCHDOG: {ENABLE_WATCHDOG}, ERROR: {ERROR}",
+                   "ENABLE_WATCHDOG", enableWatchdog, "ERROR", e);
         elog<InternalFailure>();
     }
 }
@@ -74,8 +73,8 @@
             // Retry the request once in case the cached service was stale
             return getProperties();
         }
-        log<level::ERR>("WatchdogService: Method error getting properties",
-                        entry("ERROR=%s", e.what()));
+        lg2::error("WatchdogService: Method error getting properties: {ERROR}",
+                   "ERROR", e);
         elog<InternalFailure>();
     }
 
@@ -98,8 +97,8 @@
     }
     catch (const std::exception& e)
     {
-        log<level::ERR>("WatchdogService: Decode error in get properties",
-                        entry("ERROR=%s", e.what()));
+        lg2::error("WatchdogService: Decode error in get properties: {ERROR}",
+                   "ERROR", e);
         elog<InternalFailure>();
     }
 
@@ -130,9 +129,8 @@
             // Retry the request once in case the cached service was stale
             return getProperty<T>(key);
         }
-        log<level::ERR>("WatchdogService: Method error getting property",
-                        entry("PROPERTY=%s", key.c_str()),
-                        entry("ERROR=%s", e.what()));
+        lg2::error("WatchdogService: Method error getting {PROPERTY}: {ERROR}",
+                   "PROPERTY", key, "ERROR", e);
         elog<InternalFailure>();
     }
 
@@ -161,9 +159,8 @@
             setProperty(key, val);
             return;
         }
-        log<level::ERR>("WatchdogService: Method error setting property",
-                        entry("PROPERTY=%s", key.c_str()),
-                        entry("ERROR=%s", e.what()));
+        lg2::error("WatchdogService: Method error setting {PROPERTY}: {ERROR}",
+                   "PROPERTY", key, "ERROR", e);
         elog<InternalFailure>();
     }
 }