logging: switch networkd static_library to lg2

This commit switches logging to lg2 in the following files -
1. src/dhcp_configuration.cpp
2. src/dhcp_configuration.cpp
3. src/ipaddress.cpp
4. src/system_configuration.cpp
5. src/system_queries.cpp

Tested: Build passes with "ninja -C build".

Change-Id: I492c7579c968810b783836b652e450ff89b8cd4b
Signed-off-by: Jagpal Singh Gill <paligill@gmail.com>
diff --git a/src/system_configuration.cpp b/src/system_configuration.cpp
index 58b6dfc..f817dfe 100644
--- a/src/system_configuration.cpp
+++ b/src/system_configuration.cpp
@@ -1,7 +1,7 @@
 #include "system_configuration.hpp"
 
 #include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 #include <stdplus/pinned.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 
@@ -14,7 +14,6 @@
 static constexpr char HOSTNAMED_OBJ[] = "/org/freedesktop/hostname1";
 static constexpr char HOSTNAMED_INTF[] = "org.freedesktop.hostname1";
 
-using namespace phosphor::logging;
 using namespace sdbusplus::xyz::openbmc_project::Common::Error;
 
 static constexpr char propMatch[] =
@@ -44,10 +43,8 @@
             }
             catch (const std::exception& e)
             {
-                log<level::ERR>(
-                    fmt::format("Hostname match parsing failed: {}", e.what())
-                        .c_str(),
-                    entry("ERROR=%s", e.what()));
+                lg2::error("Hostname match parsing failed: {ERROR}", "ERROR",
+                           e);
             }
         })
 {
@@ -65,8 +62,7 @@
     }
     catch (const std::exception& e)
     {
-        auto msg = fmt::format("Failed to get hostname: {}", e.what());
-        log<level::ERR>(msg.c_str(), entry("ERROR=%s", e.what()));
+        lg2::error("Failed to get hostname: {ERROR}", "ERROR", e);
     }
 
     emit_object_added();
@@ -88,8 +84,7 @@
     }
     catch (const std::exception& e)
     {
-        auto msg = fmt::format("Failed to set hostname: {}", e.what());
-        log<level::ERR>(msg.c_str(), entry("ERROR=%s", e.what()));
+        lg2::error("Failed to set hostname: {ERROR}", "ERROR", e);
     }
     return SystemConfigIntf::hostName();
 }