logging: switch networkd static_library to lg2

This commit switches logging to lg2 in the following files -
1. src/network_manager.cpp
2. src/util.cpp
3. src/ethernet_interface.cpp

Tested: Build passes with "ninja -C build".
Change-Id: Ib2492116ecf3f41f9cd0146dc4b5389a59bce87c
Signed-off-by: Jagpal Singh Gill <paligill@gmail.com>
diff --git a/src/network_manager.cpp b/src/network_manager.cpp
index 060242c..ffcae48 100644
--- a/src/network_manager.cpp
+++ b/src/network_manager.cpp
@@ -12,7 +12,7 @@
 
 #include <filesystem>
 #include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 #include <sdbusplus/message.hpp>
 #include <stdplus/pinned.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
@@ -70,11 +70,8 @@
             }
             catch (const std::exception& e)
             {
-                log<level::ERR>(
-                    fmt::format("AdministrativeState match parsing failed: {}",
-                                e.what())
-                        .c_str(),
-                    entry("ERROR=%s", e.what()));
+                lg2::error("AdministrativeState match parsing failed: {ERROR}",
+                           "ERROR", e);
             }
         })
 {
@@ -87,8 +84,8 @@
             }
             catch (const std::exception& ex)
             {
-                log<level::ERR>("Failed executing reload hook, ignoring",
-                                entry("ERR=%s", ex.what()));
+                lg2::error("Failed executing reload hook, ignoring: {ERROR}",
+                           "ERROR", ex);
             }
         }
         reloadPreHooks.clear();
@@ -98,12 +95,11 @@
                 .new_method_call(NETWORKD_BUSNAME, NETWORKD_PATH,
                                  NETWORKD_INTERFACE, "Reload")
                 .call();
-            log<level::INFO>("Reloaded systemd-networkd");
+            lg2::info("Reloaded systemd-networkd");
         }
         catch (const sdbusplus::exception_t& ex)
         {
-            log<level::ERR>("Failed to reload configuration",
-                            entry("ERR=%s", ex.what()));
+            lg2::error("Failed to reload configuration: {ERROR}", "ERROR", ex);
             reloadPostHooks.clear();
         }
         for (auto& hook : reloadPostHooks)
@@ -114,8 +110,8 @@
             }
             catch (const std::exception& ex)
             {
-                log<level::ERR>("Failed executing reload hook, ignoring",
-                                entry("ERR=%s", ex.what()));
+                lg2::error("Failed executing reload hook, ignoring: {ERROR}",
+                           "ERROR", ex);
             }
         }
         reloadPostHooks.clear();
@@ -189,9 +185,8 @@
     }
     if (!info.intf.name)
     {
-        auto msg = fmt::format("Can't create interface without name: {}",
-                               info.intf.idx);
-        log<level::ERR>(msg.c_str(), entry("IFIDX=%u", info.intf.idx));
+        lg2::error("Can't create interface without name: {IFIDX}", "IFIDX",
+                   info.intf.idx);
         return;
     }
     config::Parser config(config::pathForIntfConf(confDir, *info.intf.name));
@@ -220,8 +215,8 @@
             if (!ignored.contains(*info.name))
             {
                 ignored.emplace(*info.name);
-                auto msg = fmt::format("Ignoring interface {}\n", *info.name);
-                log<level::INFO>(msg.c_str());
+                lg2::info("Ignoring interface {INTERFACE_NAME}",
+                          "INTERFACE_NAME", *info.name);
             }
             ignoredIntf.emplace(info.idx);
             return;
@@ -403,8 +398,7 @@
     }
     else if (!ignoredIntf.contains(ifidx))
     {
-        auto msg = fmt::format("Interface `{}` not found for gw", ifidx);
-        log<level::ERR>(msg.c_str(), entry("IFIDX=%u", ifidx));
+        lg2::error("Interface {IFIDX} not found for gw", "IFIDX", ifidx);
     }
 }
 
@@ -470,7 +464,7 @@
 {
     if (id == 0 || id >= 4095)
     {
-        log<level::ERR>("VLAN ID is not valid", entry("VLANID=%u", id));
+        lg2::error("VLAN ID {VLAN_ID} is not valid", "VLAN_ID", id);
         elog<InvalidArgument>(
             Argument::ARGUMENT_NAME("VLANId"),
             Argument::ARGUMENT_VALUE(std::to_string(id).c_str()));
@@ -493,7 +487,7 @@
         std::error_code ec;
         std::filesystem::remove(dirent.path(), ec);
     }
-    log<level::INFO>("Network data purged.");
+    lg2::info("Network data purged.");
 }
 
 // Need to merge the below function with the code which writes the