convert channel_mgmt.cpp to use lg2

Change-Id: I4bd78d3aa3bf3c5717fcf3e2a9186888587456d1
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/user_channel/channel_mgmt.cpp b/user_channel/channel_mgmt.cpp
index ac907de..841cce5 100644
--- a/user_channel/channel_mgmt.cpp
+++ b/user_channel/channel_mgmt.cpp
@@ -26,7 +26,7 @@
 
 #include <boost/interprocess/sync/scoped_lock.hpp>
 #include <ipmid/utils.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 #include <sdbusplus/bus/match.hpp>
 #include <sdbusplus/server/object.hpp>
 
@@ -155,8 +155,7 @@
 {
     if (!isValidChannel(chNum))
     {
-        log<level::ERR>("Invalid channel number.",
-                        entry("CHANNEL_ID=%d", chNum));
+        lg2::error("Invalid channel number: {CHANNEL_ID}", "CHANNEL_ID", chNum);
         throw std::invalid_argument("Invalid channel number");
     }
 
@@ -173,8 +172,7 @@
             return it.chID;
         }
     }
-    log<level::ERR>("Invalid channel name.",
-                    entry("CHANNEL=%s", chName.c_str()));
+    lg2::error("Invalid channel name: {CHANNEL}", "CHANNEL", chName);
     throw std::invalid_argument("Invalid channel name");
 
     return -1;
@@ -186,7 +184,7 @@
     if (((length + 1) >= path.size()) ||
         path.compare(0, length, networkIntfObjectBasePath))
     {
-        log<level::ERR>("Invalid object path.", entry("PATH=%s", path.c_str()));
+        lg2::error("Invalid object path: {PATH}", "PATH", path);
         throw std::invalid_argument("Invalid object path");
     }
     std::string chName(path, length + 1);
@@ -204,7 +202,7 @@
     }
     catch (const std::invalid_argument& e)
     {
-        log<level::ERR>("Exception: ", entry("MSG=%s", e.what()));
+        lg2::error("Exception: {MSG}", "MSG", e.what());
         return;
     }
 
@@ -223,14 +221,13 @@
 
     if (propName != privilegePropertyString)
     {
-        log<level::ERR>("Unknown signal caught.");
+        lg2::error("Unknown signal caught.");
         return;
     }
 
     if (intfPrivStr.empty())
     {
-        log<level::ERR>("Invalid privilege string.",
-                        entry("INTF=%s", chName.c_str()));
+        lg2::error("Invalid privilege string for intf {INTF}", "INTF", chName);
         return;
     }
 
@@ -243,7 +240,7 @@
     }
     catch (const std::invalid_argument& e)
     {
-        log<level::ERR>("Exception: ", entry("MSG=%s", e.what()));
+        lg2::error("Exception: {MSG}", "MSG", e.what());
         return;
     }
 
@@ -253,7 +250,7 @@
     if (signalFlag & (1 << chNum))
     {
         signalFlag &= ~(1 << chNum);
-        log<level::DEBUG>("Request originated from IPMI so ignoring signal");
+        lg2::debug("Request originated from IPMI so ignoring signal");
         return;
     }
 
@@ -268,7 +265,7 @@
         channelData[chNum].chAccess.chNonVolatileData.privLimit = intfPriv;
         if (writeChannelPersistData() != 0)
         {
-            log<level::ERR>("Failed to update the persist data file");
+            lg2::error("Failed to update the persist data file");
             return;
         }
 
@@ -278,7 +275,7 @@
             channelData[chNum].chAccess.chVolatileData.privLimit = intfPriv;
             if (writeChannelVolatileData() != 0)
             {
-                log<level::ERR>("Failed to update the volatile data file");
+                lg2::error("Failed to update the volatile data file");
                 return;
             }
         }
@@ -311,7 +308,7 @@
                           std::ofstream::out | std::ofstream::app);
     if (!mutexCleanUpFile.good())
     {
-        log<level::DEBUG>("Unable to open mutex cleanup file");
+        lg2::debug("Unable to open mutex cleanup file");
         return;
     }
     mutexCleanUpFile.close();
@@ -340,7 +337,7 @@
     // host-ipmid
     if (chPropertiesSignal == nullptr && sigHndlrLock.try_lock())
     {
-        log<level::DEBUG>("Registering channel signal handler.");
+        lg2::debug("Registering channel signal handler.");
         chPropertiesSignal = std::make_unique<sdbusplus::bus::match_t>(
             bus,
             sdbusplus::bus::match::rules::path_namespace(
@@ -381,13 +378,13 @@
 {
     if (chNum >= maxIpmiChannels)
     {
-        log<level::DEBUG>("Invalid channel ID - Out of range");
+        lg2::debug("Invalid channel ID - Out of range");
         return false;
     }
 
     if (channelData[chNum].isChValid == false)
     {
-        log<level::DEBUG>("Channel is not valid");
+        lg2::debug("Channel is not valid");
     }
 
     return channelData[chNum].isChValid;
@@ -406,14 +403,14 @@
 {
     if ((authType < EAuthType::md2) || (authType > EAuthType::oem))
     {
-        log<level::DEBUG>("Invalid authentication type");
+        lg2::debug("Invalid authentication type");
         return false;
     }
 
     uint8_t authTypeSupported = channelData[chNum].chInfo.authTypeSupported;
     if (!(authTypeSupported & (1 << static_cast<uint8_t>(authType))))
     {
-        log<level::DEBUG>("Authentication type is not supported.");
+        lg2::debug("Authentication type is not supported.");
         return false;
     }
 
@@ -439,7 +436,7 @@
 {
     if (!isValidChannel(chNum))
     {
-        log<level::DEBUG>("Invalid channel");
+        lg2::debug("Invalid channel");
         return ccInvalidFieldRequest;
     }
 
@@ -454,13 +451,13 @@
 {
     if (!isValidChannel(chNum))
     {
-        log<level::DEBUG>("Invalid channel");
+        lg2::debug("Invalid channel");
         return ccInvalidFieldRequest;
     }
 
     if (getChannelSessionSupport(chNum) == EChannelSessSupported::none)
     {
-        log<level::DEBUG>("Session-less channel doesn't have access data.");
+        lg2::debug("Session-less channel doesn't have access data.");
         return ccActionNotSupportedForChannel;
     }
 
@@ -483,25 +480,25 @@
 {
     if (!isValidChannel(chNum))
     {
-        log<level::DEBUG>("Invalid channel");
+        lg2::debug("Invalid channel");
         return ccInvalidFieldRequest;
     }
 
     if (getChannelSessionSupport(chNum) == EChannelSessSupported::none)
     {
-        log<level::DEBUG>("Session-less channel doesn't have access data.");
+        lg2::debug("Session-less channel doesn't have access data.");
         return ccActionNotSupportedForChannel;
     }
 
     if ((setFlag & setAccessMode) &&
         (!isValidAccessMode(chAccessData.accessMode)))
     {
-        log<level::DEBUG>("Invalid access mode specified");
+        lg2::debug("Invalid access mode specified");
         return ccAccessModeNotSupportedForChannel;
     }
     if ((setFlag & setPrivLimit) && (!isValidPrivLimit(chAccessData.privLimit)))
     {
-        log<level::DEBUG>("Invalid privilege limit specified");
+        lg2::debug("Invalid privilege limit specified");
         return ccInvalidFieldRequest;
     }
 
@@ -542,7 +539,7 @@
     // Write Volatile data to file
     if (writeChannelVolatileData() != 0)
     {
-        log<level::DEBUG>("Failed to update the channel volatile data");
+        lg2::debug("Failed to update the channel volatile data");
         return ccUnspecifiedError;
     }
     return ccSuccess;
@@ -553,13 +550,13 @@
 {
     if (!isValidChannel(chNum))
     {
-        log<level::DEBUG>("Invalid channel");
+        lg2::debug("Invalid channel");
         return ccInvalidFieldRequest;
     }
 
     if (getChannelSessionSupport(chNum) == EChannelSessSupported::none)
     {
-        log<level::DEBUG>("Session-less channel doesn't have access data.");
+        lg2::debug("Session-less channel doesn't have access data.");
         return ccActionNotSupportedForChannel;
     }
 
@@ -582,25 +579,25 @@
 {
     if (!isValidChannel(chNum))
     {
-        log<level::DEBUG>("Invalid channel");
+        lg2::debug("Invalid channel");
         return ccInvalidFieldRequest;
     }
 
     if (getChannelSessionSupport(chNum) == EChannelSessSupported::none)
     {
-        log<level::DEBUG>("Session-less channel doesn't have access data.");
+        lg2::debug("Session-less channel doesn't have access data.");
         return ccActionNotSupportedForChannel;
     }
 
     if ((setFlag & setAccessMode) &&
         (!isValidAccessMode(chAccessData.accessMode)))
     {
-        log<level::DEBUG>("Invalid access mode specified");
+        lg2::debug("Invalid access mode specified");
         return ccAccessModeNotSupportedForChannel;
     }
     if ((setFlag & setPrivLimit) && (!isValidPrivLimit(chAccessData.privLimit)))
     {
-        log<level::DEBUG>("Invalid privilege limit specified");
+        lg2::debug("Invalid privilege limit specified");
         return ccInvalidFieldRequest;
     }
 
@@ -644,15 +641,14 @@
                                      networkChConfigIntfName,
                                      privilegePropertyString, privStr))
             {
-                log<level::DEBUG>(
-                    "Network interface does not exist",
-                    entry("INTERFACE=%s", channelData[chNum].chName.c_str()));
+                lg2::debug("Network interface '{INTERFACE}' does not exist",
+                           "INTERFACE", channelData[chNum].chName);
                 return ccUnspecifiedError;
             }
         }
         catch (const sdbusplus::exception_t& e)
         {
-            log<level::ERR>("Exception: Network interface does not exist");
+            lg2::error("Exception: Network interface does not exist");
             return ccInvalidFieldRequest;
         }
         signalFlag |= (1 << chNum);
@@ -663,7 +659,7 @@
     // Write persistent data to file
     if (writeChannelPersistData() != 0)
     {
-        log<level::DEBUG>("Failed to update the presist data file");
+        lg2::debug("Failed to update the presist data file");
         return ccUnspecifiedError;
     }
     return ccSuccess;
@@ -674,7 +670,7 @@
 {
     if (!isValidChannel(chNum))
     {
-        log<level::DEBUG>("Invalid channel");
+        lg2::debug("Invalid channel");
         return ccInvalidFieldRequest;
     }
 
@@ -688,19 +684,19 @@
 {
     if (!isValidChannel(chNum))
     {
-        log<level::DEBUG>("Invalid channel");
+        lg2::debug("Invalid channel");
         return ccInvalidFieldRequest;
     }
 
     if (getChannelSessionSupport(chNum) == EChannelSessSupported::none)
     {
-        log<level::DEBUG>("Sessionless channel doesn't have access data.");
+        lg2::debug("Sessionless channel doesn't have access data.");
         return ccInvalidFieldRequest;
     }
 
     if (!isValidPrivLimit(priv))
     {
-        log<level::DEBUG>("Invalid privilege specified.");
+        lg2::debug("Invalid privilege specified.");
         return ccInvalidFieldRequest;
     }
 
@@ -715,7 +711,7 @@
     struct stat fileStat;
     if (stat(fileName.c_str(), &fileStat) != 0)
     {
-        log<level::DEBUG>("Error in getting last updated time stamp");
+        lg2::debug("Error in getting last updated time stamp");
         return -EIO;
     }
     return fileStat.st_mtime;
@@ -727,8 +723,7 @@
     auto iter = std::find(accessModeList.begin(), accessModeList.end(), mode);
     if (iter == accessModeList.end())
     {
-        log<level::ERR>("Invalid access mode.",
-                        entry("MODE_STR=%s", mode.c_str()));
+        lg2::error("Invalid access mode: {MODE_STR}", "MODE_STR", mode);
         throw std::invalid_argument("Invalid access mode.");
     }
 
@@ -740,7 +735,7 @@
 {
     if (accessModeList.size() <= value)
     {
-        log<level::ERR>("Invalid access mode.", entry("MODE_IDX=%d", value));
+        lg2::error("Invalid access mode: {MODE_IDX}", "MODE_IDX", value);
         throw std::invalid_argument("Invalid access mode.");
     }
 
@@ -753,8 +748,7 @@
     auto iter = std::find(privList.begin(), privList.end(), value);
     if (iter == privList.end())
     {
-        log<level::ERR>("Invalid privilege.",
-                        entry("PRIV_STR=%s", value.c_str()));
+        lg2::error("Invalid privilege: {PRIV_STR}", "PRIV_STR", value);
         throw std::invalid_argument("Invalid privilege.");
     }
 
@@ -765,7 +759,7 @@
 {
     if (privList.size() <= value)
     {
-        log<level::ERR>("Invalid privilege.", entry("PRIV_IDX=%d", value));
+        lg2::error("Invalid privilege: {PRIV_IDX.", "PRIV_IDX", value);
         throw std::invalid_argument("Invalid privilege.");
     }
 
@@ -779,8 +773,7 @@
                           value);
     if (iter == sessionSupportList.end())
     {
-        log<level::ERR>("Invalid session supported.",
-                        entry("SESS_STR=%s", value.c_str()));
+        lg2::error("Invalid session supported: {SESS_STR}", "SESS_STR", value);
         throw std::invalid_argument("Invalid session supported.");
     }
 
@@ -795,8 +788,7 @@
         mediumTypeMap.find(value);
     if (it == mediumTypeMap.end())
     {
-        log<level::ERR>("Invalid medium type.",
-                        entry("MEDIUM_STR=%s", value.c_str()));
+        lg2::error("Invalid medium type: {MEDIUM_STR}", "MEDIUM_STR", value);
         throw std::invalid_argument("Invalid medium type.");
     }
 
@@ -810,8 +802,7 @@
         protocolTypeMap.find(value);
     if (it == protocolTypeMap.end())
     {
-        log<level::ERR>("Invalid protocol type.",
-                        entry("PROTO_STR=%s", value.c_str()));
+        lg2::error("Invalid protocol type: {PROTO_STR}", "PROTO_STR", value);
         throw std::invalid_argument("Invalid protocol type.");
     }
 
@@ -823,8 +814,7 @@
     std::ifstream jsonFile(configFile);
     if (!jsonFile.good())
     {
-        log<level::INFO>("JSON file not found",
-                         entry("FILE_NAME=%s", configFile.c_str()));
+        lg2::info("JSON file '{FILE_NAME}' not found", "FILE_NAME", configFile);
         return nullptr;
     }
 
@@ -835,8 +825,7 @@
     }
     catch (const Json::parse_error& e)
     {
-        log<level::DEBUG>("Corrupted channel config.",
-                          entry("MSG=%s", e.what()));
+        lg2::debug("Corrupted channel config: {MSG}", "MSG", e.what());
         throw std::runtime_error("Corrupted channel config file");
     }
 
@@ -851,8 +840,8 @@
                   S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
     if (fd < 0)
     {
-        log<level::ERR>("Error in creating json file",
-                        entry("FILE_NAME = %s", tmpFile.c_str()));
+        lg2::error("Error in creating json file '{FILE_NAME}'", "FILE_NAME",
+                   tmpFile);
         return -EIO;
     }
     const auto& writeData = jsonData.dump();
@@ -860,16 +849,16 @@
         static_cast<ssize_t>(writeData.size()))
     {
         close(fd);
-        log<level::ERR>("Error in writing configuration file",
-                        entry("FILE_NAME = %s", tmpFile.c_str()));
+        lg2::error("Error in writing configuration file '{FILE_NAME}'",
+                   "FILE_NAME", tmpFile);
         return -EIO;
     }
     close(fd);
 
     if (std::rename(tmpFile.c_str(), configFile.c_str()) != 0)
     {
-        log<level::ERR>("Error in renaming temporary data file",
-                        entry("FILE_NAME = %s", tmpFile.c_str()));
+        lg2::error("Error in renaming temporary data file '{FILE_NAME}'",
+                   "FILE_NAME", tmpFile);
         return -EIO;
     }
 
@@ -928,7 +917,7 @@
     Json data = readJsonFile(channelConfigDefaultFilename);
     if (data.empty())
     {
-        log<level::DEBUG>("Error in opening IPMI Channel data file");
+        lg2::debug("Error in opening IPMI Channel data file");
         return -EIO;
     }
 
@@ -939,7 +928,7 @@
     struct ifaddrs *ifaddr = nullptr, *ifa = nullptr;
     if (int err = getifaddrs(&ifaddr); err < 0)
     {
-        log<level::DEBUG>("Unable to acquire network interfaces");
+        lg2::debug("Unable to acquire network interfaces");
         return -EIO;
     }
 
@@ -959,7 +948,7 @@
             Json jsonChInfo = jsonChData[channelInfoString].get<Json>();
             if (jsonChInfo.is_null())
             {
-                log<level::ERR>("Invalid/corrupted channel config file");
+                lg2::error("Invalid/corrupted channel config file");
                 freeifaddrs(ifaddr);
                 return -EBADMSG;
             }
@@ -1010,15 +999,14 @@
         }
         catch (const Json::exception& e)
         {
-            log<level::DEBUG>("Json Exception caught.",
-                              entry("MSG=%s", e.what()));
+            lg2::debug("Json Exception caught: {MSG}", "MSG", e.what());
             freeifaddrs(ifaddr);
 
             return -EBADMSG;
         }
         catch (const std::invalid_argument& e)
         {
-            log<level::ERR>("Corrupted config.", entry("MSG=%s", e.what()));
+            lg2::error("Corrupted config: {MSG}", "MSG", e.what());
             freeifaddrs(ifaddr);
             return -EBADMSG;
         }
@@ -1036,7 +1024,7 @@
     Json data = readJsonFile(channelVolatileDataFilename);
     if (data == nullptr)
     {
-        log<level::DEBUG>("Error in opening IPMI Channel data file");
+        lg2::debug("Error in opening IPMI Channel data file");
         return -EIO;
     }
     try
@@ -1048,8 +1036,7 @@
             uint8_t chNum = std::stoi(chKey, nullptr, 10);
             if (chNum >= maxIpmiChannels)
             {
-                log<level::DEBUG>(
-                    "Invalid channel access entry in config file");
+                lg2::debug("Invalid channel access entry in config file");
                 throw std::out_of_range("Out of range - channel number");
             }
             Json jsonChData = it.value();
@@ -1072,9 +1059,9 @@
             }
             else
             {
-                log<level::ERR>(
-                    "Invalid/corrupted volatile channel access file",
-                    entry("FILE=%s", channelVolatileDataFilename));
+                lg2::error(
+                    "Invalid/corrupted volatile channel access file '{FILE}'",
+                    "FILE", channelVolatileDataFilename);
                 throw std::runtime_error(
                     "Corrupted volatile channel access file");
             }
@@ -1082,12 +1069,12 @@
     }
     catch (const Json::exception& e)
     {
-        log<level::DEBUG>("Json Exception caught.", entry("MSG=%s", e.what()));
+        lg2::debug("Json Exception caught: {MSG}", "MSG", e.what());
         throw std::runtime_error("Corrupted volatile channel access file");
     }
     catch (const std::invalid_argument& e)
     {
-        log<level::ERR>("Corrupted config.", entry("MSG=%s", e.what()));
+        lg2::error("Corrupted config: {MSG}", "MSG", e.what());
         throw std::runtime_error("Corrupted volatile channel access file");
     }
 
@@ -1104,7 +1091,7 @@
     Json data = readJsonFile(channelNvDataFilename);
     if (data == nullptr)
     {
-        log<level::DEBUG>("Error in opening IPMI Channel data file");
+        lg2::debug("Error in opening IPMI Channel data file");
         return -EIO;
     }
     try
@@ -1116,8 +1103,7 @@
             uint8_t chNum = std::stoi(chKey, nullptr, 10);
             if (chNum >= maxIpmiChannels)
             {
-                log<level::DEBUG>(
-                    "Invalid channel access entry in config file");
+                lg2::debug("Invalid channel access entry in config file");
                 throw std::out_of_range("Out of range - channel number");
             }
             Json jsonChData = it.value();
@@ -1141,20 +1127,20 @@
             }
             else
             {
-                log<level::ERR>("Invalid/corrupted nv channel access file",
-                                entry("FILE=%s", channelNvDataFilename));
+                lg2::error("Invalid/corrupted nv channel access file {FILE}",
+                           "FILE", channelNvDataFilename);
                 throw std::runtime_error("Corrupted nv channel access file");
             }
         }
     }
     catch (const Json::exception& e)
     {
-        log<level::DEBUG>("Json Exception caught.", entry("MSG=%s", e.what()));
+        lg2::debug("Json Exception caught: {MSG}", "MSG", e.what());
         throw std::runtime_error("Corrupted nv channel access file");
     }
     catch (const std::invalid_argument& e)
     {
-        log<level::ERR>("Corrupted config.", entry("MSG=%s", e.what()));
+        lg2::error("Corrupted config: {MSG}", "MSG", e.what());
         throw std::runtime_error("Corrupted nv channel access file");
     }
 
@@ -1197,13 +1183,13 @@
     }
     catch (const std::invalid_argument& e)
     {
-        log<level::ERR>("Corrupted config.", entry("MSG=%s", e.what()));
+        lg2::error("Corrupted config: {MSG}", "MSG", e.what());
         return -EINVAL;
     }
 
     if (writeJsonFile(channelVolatileDataFilename, outData) != 0)
     {
-        log<level::DEBUG>("Error in write JSON data to file");
+        lg2::debug("Error in write JSON data to file");
         return -EIO;
     }
 
@@ -1248,13 +1234,13 @@
     }
     catch (const std::invalid_argument& e)
     {
-        log<level::ERR>("Corrupted config.", entry("MSG=%s", e.what()));
+        lg2::error("Corrupted config: {MSG}", "MSG", e.what());
         return -EINVAL;
     }
 
     if (writeJsonFile(channelNvDataFilename, outData) != 0)
     {
-        log<level::DEBUG>("Error in write JSON data to file");
+        lg2::debug("Error in write JSON data to file");
         return -EIO;
     }
 
@@ -1275,8 +1261,8 @@
         }
         catch (const std::exception& e)
         {
-            log<level::ERR>("Exception caught in readChannelPersistData.",
-                            entry("MSG=%s", e.what()));
+            lg2::error("Exception caught in readChannelPersistData: {MSG}",
+                       "MSG", e.what());
             ret = -EIO;
         }
     }
@@ -1295,8 +1281,8 @@
         }
         catch (const std::exception& e)
         {
-            log<level::ERR>("Exception caught in readChannelVolatileData.",
-                            entry("MSG=%s", e.what()));
+            lg2::error("Exception caught in readChannelVolatileData: {MSG}",
+                       "MSG", e.what());
             ret = -EIO;
         }
     }
@@ -1321,11 +1307,10 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::DEBUG>("set-property failed",
-                          entry("SERVICE=%s", service.c_str()),
-                          entry("OBJPATH=%s", objPath.c_str()),
-                          entry("INTERFACE=%s", interface.c_str()),
-                          entry("PROP=%s", property.c_str()));
+        lg2::debug(
+            "set-property {SERVICE}:{OBJPATH}/{INTERFACE}.{PROP} failed: {MSG}",
+            "SERVICE", service, "OBJPATH", objPath, "INTERFACE", interface,
+            "PROP", property);
         return -EIO;
     }
 
@@ -1358,19 +1343,19 @@
             }
             catch (const std::bad_variant_access& e)
             {
-                log<level::DEBUG>(
-                    "exception: Network interface does not exist");
+                lg2::debug("Network interface '{INTERFACE}' does not exist",
+                           "INTERFACE", channelData[chNum].chName);
                 continue;
             }
             catch (const sdbusplus::exception_t& e)
             {
-                log<level::DEBUG>(
-                    "exception: Network interface does not exist");
+                lg2::debug("Network interface '{INTERFACE}' does not exist",
+                           "INTERFACE", channelData[chNum].chName);
                 continue;
             }
             catch (const std::invalid_argument& e)
             {
-                log<level::DEBUG>("exception: Invalid privilege");
+                lg2::debug("exception: Invalid privilege");
                 continue;
             }
 
@@ -1390,13 +1375,13 @@
         // Write persistent data to file
         if (writeChannelPersistData() != 0)
         {
-            log<level::DEBUG>("Failed to update the persistent data file");
+            lg2::debug("Failed to update the persistent data file");
             return -EIO;
         }
         // Write Volatile data to file
         if (writeChannelVolatileData() != 0)
         {
-            log<level::DEBUG>("Failed to update the channel volatile data");
+            lg2::debug("Failed to update the channel volatile data");
             return -EIO;
         }
     }
@@ -1412,7 +1397,7 @@
     /* Always read the channel config */
     if (loadChannelConfig() != 0)
     {
-        log<level::ERR>("Failed to read channel config file");
+        lg2::error("Failed to read channel config file");
         throw std::ios_base::failure("Failed to load channel configuration");
     }
 
@@ -1426,7 +1411,7 @@
         // Load the channel access NV data
         if (readChannelPersistData() != 0)
         {
-            log<level::ERR>("Failed to read channel access NV data");
+            lg2::error("Failed to read channel access NV data");
             throw std::ios_base::failure(
                 "Failed to read channel access NV configuration");
         }
@@ -1444,7 +1429,7 @@
         // Load the channel access volatile data
         if (readChannelVolatileData() != 0)
         {
-            log<level::ERR>("Failed to read channel access volatile data");
+            lg2::error("Failed to read channel access volatile data");
             throw std::ios_base::failure(
                 "Failed to read channel access volatile configuration");
         }
@@ -1454,13 +1439,13 @@
     // configuration(priv) over dbus
     if (syncNetworkChannelConfig() != 0)
     {
-        log<level::ERR>(
+        lg2::error(
             "Failed to synchronize data with network channel config over dbus");
         throw std::ios_base::failure(
             "Failed to synchronize data with network channel config over dbus");
     }
 
-    log<level::DEBUG>("Successfully completed channel data initialization.");
+    lg2::debug("Successfully completed channel data initialization.");
     return;
 }