treewide: Make logging variables more consistent

This aims to better group related variables and differentiate keywords
like INTERFACE_NAME into NET vs DBUS.

Tested: Ran on a machine to verify that our info log messages still look
sane in the journal.

Change-Id: Ic4d1faaaf5c432e69cacd387fa972481916b6bc8
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/dhcp_configuration.cpp b/src/dhcp_configuration.cpp
index 8843c7c..c649568 100644
--- a/src/dhcp_configuration.cpp
+++ b/src/dhcp_configuration.cpp
@@ -44,7 +44,7 @@
     }
     if (newest_file != std::filesystem::directory_entry{})
     {
-        lg2::info("Using DHCP options from {FILE}", "FILE",
+        lg2::info("Using DHCP options from {CFG_FILE}", "CFG_FILE",
                   newest_file.path().native());
         conf.setFile(newest_file.path());
     }
diff --git a/src/ethernet_interface.cpp b/src/ethernet_interface.cpp
index ef0355a..a273934 100644
--- a/src/ethernet_interface.cpp
+++ b/src/ethernet_interface.cpp
@@ -57,8 +57,8 @@
     }
     catch (const std::exception& e)
     {
-        lg2::error("{MSG} failed on {INTERFACE_NAME}: {ERROR}", "MSG", msg,
-                   "INTERFACE_NAME", intf, "ERROR", e);
+        lg2::error("{MSG} failed on {NET_INTF}: {ERROR}", "MSG", msg,
+                   "NET_INTF", intf, "ERROR", e);
     }
     return fallback;
 }
@@ -195,7 +195,7 @@
 {
     if (!info.mac || !info.addr)
     {
-        lg2::error("Missing neighbor mac on {INTERFACE_NAME}", "INTERFACE_NAME",
+        lg2::error("Missing neighbor mac on {NET_INTF}", "NET_INTF",
                    interfaceName());
         return;
     }
@@ -233,8 +233,8 @@
     }
     catch (const std::exception& e)
     {
-        lg2::error("Invalid IP {IP_ADDRESS}: {ERROR}", "IP_ADDRESS", ipaddress,
-                   "ERROR", e);
+        lg2::error("Invalid IP {NET_IP}: {ERROR}", "NET_IP", ipaddress, "ERROR",
+                   e);
         elog<InvalidArgument>(Argument::ARGUMENT_NAME("ipaddress"),
                               Argument::ARGUMENT_VALUE(ipaddress.c_str()));
     }
@@ -245,8 +245,8 @@
     }
     catch (const std::exception& e)
     {
-        lg2::error("Invalid prefix length {PREFIXLENGTH}: {ERROR}",
-                   "PREFIXLENGTH", prefixLength, "ERROR", e);
+        lg2::error("Invalid prefix length {NET_PFX}: {ERROR}", "NET_PFX",
+                   prefixLength, "ERROR", e);
         elog<InvalidArgument>(
             Argument::ARGUMENT_NAME("prefixLength"),
             Argument::ARGUMENT_VALUE(std::to_string(prefixLength).c_str()));
@@ -285,7 +285,7 @@
     }
     catch (const std::exception& e)
     {
-        lg2::error("Not a valid IP address {IP_ADDRESS}: {ERROR}", "IP_ADDRESS",
+        lg2::error("Not a valid IP address {NET_IP}: {ERROR}", "NET_IP",
                    ipAddress, "ERROR", e);
         elog<InvalidArgument>(Argument::ARGUMENT_NAME("ipAddress"),
                               Argument::ARGUMENT_VALUE(ipAddress.c_str()));
@@ -298,8 +298,8 @@
     }
     catch (const std::exception& e)
     {
-        lg2::error("Not a valid MAC address {MAC_ADDRESS}: {ERROR}",
-                   "MAC_ADDRESS", macAddress, "ERROR", e);
+        lg2::error("Not a valid MAC address {NET_MAC}: {ERROR}", "NET_MAC",
+                   macAddress, "ERROR", e);
         elog<InvalidArgument>(Argument::ARGUMENT_NAME("macAddress"),
                               Argument::ARGUMENT_VALUE(macAddress.c_str()));
     }
@@ -438,8 +438,8 @@
         }
         catch (const std::exception& e)
         {
-            lg2::error("Not a valid IP address {IP_ADDRESS}: {ERROR}",
-                       "IP_ADDRESS", ip, "ERROR", e);
+            lg2::error("Not a valid IP address {NET_IP}: {ERROR}", "NET_IP", ip,
+                       "ERROR", e);
             elog<InvalidArgument>(Argument::ARGUMENT_NAME("StaticNameserver"),
                                   Argument::ARGUMENT_VALUE(ip.c_str()));
         }
@@ -491,7 +491,7 @@
     catch (const sdbusplus::exception::SdBusError& e)
     {
         lg2::error("Failed to get NTP server information from "
-                   "Systemd-Timesyncd: {ERROR}",
+                   "systemd-timesyncd: {ERROR}",
                    "ERROR", e);
     }
 
@@ -534,7 +534,7 @@
     catch (const sdbusplus::exception_t& e)
     {
         lg2::error(
-            "Failed to get DNS information from Systemd-Resolved: {ERROR}",
+            "Failed to get DNS information from systemd-resolved: {ERROR}",
             "ERROR", e);
     }
     auto tupleVector = std::get_if<type>(&name);
@@ -555,7 +555,7 @@
     if (manager.get().interfaces.find(intfName) !=
         manager.get().interfaces.end())
     {
-        lg2::error("VLAN {VLAN_ID} already exists", "VLAN_ID", id);
+        lg2::error("VLAN {NET_VLAN} already exists", "NET_VLAN", id);
         elog<InvalidArgument>(Argument::ARGUMENT_NAME("VLANId"),
                               Argument::ARGUMENT_VALUE(idStr.c_str()));
     }
@@ -737,7 +737,7 @@
     auto path = config::pathForIntfConf(manager.get().getConfDir(),
                                         interfaceName());
     config.writeFile(path);
-    lg2::info("Wrote networkd file: {FILE_PATH}", "FILE_PATH", path);
+    lg2::info("Wrote networkd file: {CFG_FILE}", "CFG_FILE", path);
 }
 
 std::string EthernetInterface::macAddress([[maybe_unused]] std::string value)
@@ -755,15 +755,13 @@
     }
     catch (const std::invalid_argument&)
     {
-        lg2::error("MAC Address {MAC_ADDRESS} is not valid", "MAC_ADDRESS",
-                   value);
+        lg2::error("MAC Address {NET_MAC} is not valid", "NET_MAC", value);
         elog<InvalidArgument>(Argument::ARGUMENT_NAME("MACAddress"),
                               Argument::ARGUMENT_VALUE(value.c_str()));
     }
     if (!mac_address::isUnicast(newMAC))
     {
-        lg2::error("MAC Address {MAC_ADDRESS} is not valid", "MAC_ADDRESS",
-                   value);
+        lg2::error("MAC Address {NET_MAC} is not valid", "NET_MAC", value);
         elog<InvalidArgument>(Argument::ARGUMENT_NAME("MACAddress"),
                               Argument::ARGUMENT_VALUE(value.c_str()));
     }
@@ -832,7 +830,7 @@
     }
     catch (const std::exception& e)
     {
-        lg2::error("Invalid v4 GW {GATEWAY}: {ERROR}", "GATEWAY", gateway,
+        lg2::error("Invalid v4 GW {NET_GW}: {ERROR}", "NET_GW", gateway,
                    "ERROR", e);
         elog<InvalidArgument>(Argument::ARGUMENT_NAME("GATEWAY"),
                               Argument::ARGUMENT_VALUE(gateway.c_str()));
@@ -861,7 +859,7 @@
     }
     catch (const std::exception& e)
     {
-        lg2::error("Invalid v6 GW {GATEWAY}: {ERROR}", "GATEWAY", gateway,
+        lg2::error("Invalid v6 GW {NET_GW}: {ERROR}", "NET_GW", gateway,
                    "ERROR", e);
         elog<InvalidArgument>(Argument::ARGUMENT_NAME("GATEWAY"),
                               Argument::ARGUMENT_VALUE(gateway.c_str()));
diff --git a/src/inventory_mac.cpp b/src/inventory_mac.cpp
index e4aad88..f865a78 100644
--- a/src/inventory_mac.cpp
+++ b/src/inventory_mac.cpp
@@ -57,9 +57,8 @@
             auto returnMAC = interface.second->macAddress(mac);
             if (returnMAC == mac)
             {
-                lg2::info(
-                    "Setting MAC {MAC_ADDRESS} on interface {INTERFACE_NAME}",
-                    "MAC_ADDRESS", mac, "INTERFACE_NAME", intf);
+                lg2::info("Setting MAC {NET_MAC} on interface {NET_INTF}",
+                          "NET_MAC", mac, "NET_INTF", intf);
                 std::error_code ec;
                 if (std::filesystem::is_directory("/var/lib/network", ec))
                 {
@@ -101,8 +100,8 @@
 
     if (objectTree.empty())
     {
-        lg2::error("No Object has implemented the interface {INTERFACE_NAME}",
-                   "INTERFACE_NAME", invNetworkIntf);
+        lg2::error("No Object has implemented the interface {NET_INTF}",
+                   "NET_INTF", invNetworkIntf);
         elog<InternalFailure>();
     }
 
@@ -120,8 +119,8 @@
         // interface name
         for (const auto& object : objectTree)
         {
-            lg2::info("Get info on interface {INTERFACE_NAME}, object {OBJECT}",
-                      "INTERFACE_NAME", interfaceName, "OBJECT", object.first);
+            lg2::info("Get info on interface {NET_INTF}, object {OBJ}",
+                      "NET_INTF", interfaceName, "OBJ", object.first);
 
             if (std::string::npos != object.first.find(interfaceName.c_str()))
             {
@@ -133,9 +132,8 @@
 
         if (objPath.empty())
         {
-            lg2::error(
-                "Can't find the object for the interface {INTERFACE_NAME}",
-                "INTERFACE_NAME", interfaceName);
+            lg2::error("Can't find the object for the interface {NET_INTF}",
+                       "NET_INTF", interfaceName);
             elog<InternalFailure>();
         }
     }
@@ -148,9 +146,9 @@
     auto reply = bus.call(method);
     if (reply.is_method_error())
     {
-        lg2::error("Failed to get MACAddress for path {PATH} interface "
-                   "{INTERFACE_NAME}",
-                   "PATH", objPath, "INTERFACE_NAME", invNetworkIntf);
+        lg2::error(
+            "Failed to get MACAddress for path {DBUS_PATH} interface {DBUS_INTF}",
+            "DBUS_PATH", objPath, "DBUS_INTF", invNetworkIntf);
         elog<InternalFailure>();
     }
 
@@ -167,9 +165,9 @@
         if (inventoryMAC != ether_addr{})
         {
             auto macStr = std::to_string(inventoryMAC);
-            lg2::info("Mac Address {MAC_ADDRESS} in Inventory on Interface "
-                      "{INTERFACE_NAME}",
-                      "MAC_ADDRESS", macStr, "INTERFACE_NAME", intfname);
+            lg2::info(
+                "Mac Address {NET_MAC} in Inventory on Interface {NET_INTF}",
+                "NET_MAC", macStr, "NET_INTF", intfname);
             setFirstBootMACOnInterface(intfname, macStr);
             first_boot_status.push_back(intfname);
             bool status = true;
@@ -179,9 +177,8 @@
                                 first_boot_status.end(),
                                 keys.key()) != first_boot_status.end()))
                 {
-                    lg2::info(
-                        "Interface {INTERFACE_NAME} MAC is NOT set from VPD",
-                        "INTERFACE_NAME", keys.key());
+                    lg2::info("Interface {NET_INTF} MAC is NOT set from VPD",
+                              "NET_INTF", keys.key());
                     status = false;
                 }
             }
@@ -288,8 +285,8 @@
 
         for (const auto& interfaces : interfacesProperties)
         {
-            lg2::info("Check {INTERFACE_NAME} for sdbus response",
-                      "INTERFACE_NAME", interfaces.first);
+            lg2::info("Check {DBUS_INTF} for sdbus response", "DBUS_INTF",
+                      interfaces.first);
             if (interfaces.first ==
                 "xyz.openbmc_project.Network.EthernetInterface")
             {
diff --git a/src/ipaddress.cpp b/src/ipaddress.cpp
index 464a2c0..32c9462 100644
--- a/src/ipaddress.cpp
+++ b/src/ipaddress.cpp
@@ -90,10 +90,10 @@
 {
     if (origin() != IP::AddressOrigin::Static)
     {
-        lg2::error("Tried to delete a non-static address {IP_ADDRESS} prefix "
-                   "{PREFIX} interface {INTERFACE_NAME}",
-                   "IP_ADDRESS", address(), "PREFIX", prefixLength(),
-                   "INTERFACE_NAME", parent.get().interfaceName());
+        lg2::error("Tried to delete a non-static address {NET_IP} prefix "
+                   "{NET_PFX} interface {NET_INTF}",
+                   "NET_IP", address(), "NET_PFX", prefixLength(), "NET_INTF",
+                   parent.get().interfaceName());
         elog<InternalFailure>();
     }
 
diff --git a/src/network_manager.cpp b/src/network_manager.cpp
index 72e0d03..85133c7 100644
--- a/src/network_manager.cpp
+++ b/src/network_manager.cpp
@@ -186,7 +186,7 @@
     }
     if (!info.intf.name)
     {
-        lg2::error("Can't create interface without name: {IFIDX}", "IFIDX",
+        lg2::error("Can't create interface without name: {NET_IDX}", "NET_IDX",
                    info.intf.idx);
         return;
     }
@@ -216,8 +216,8 @@
             if (!ignored.contains(*info.name))
             {
                 ignored.emplace(*info.name);
-                lg2::info("Ignoring interface {INTERFACE_NAME}",
-                          "INTERFACE_NAME", *info.name);
+                lg2::info("Ignoring interface {NET_INTF}", "NET_INTF",
+                          *info.name);
             }
             ignoredIntf.emplace(info.idx);
             return;
@@ -399,7 +399,7 @@
     }
     else if (!ignoredIntf.contains(ifidx))
     {
-        lg2::error("Interface {IFIDX} not found for gw", "IFIDX", ifidx);
+        lg2::error("Interface {NET_IDX} not found for gw", "NET_IDX", ifidx);
     }
 }
 
@@ -461,7 +461,7 @@
 {
     if (id == 0 || id >= 4095)
     {
-        lg2::error("VLAN ID {VLAN_ID} is not valid", "VLAN_ID", id);
+        lg2::error("VLAN ID {NET_VLAN} is not valid", "NET_VLAN", id);
         elog<InvalidArgument>(
             Argument::ARGUMENT_NAME("VLANId"),
             Argument::ARGUMENT_VALUE(std::to_string(id).c_str()));
diff --git a/src/system_queries.cpp b/src/system_queries.cpp
index 56feb8d..0ce674f 100644
--- a/src/system_queries.cpp
+++ b/src/system_queries.cpp
@@ -67,8 +67,8 @@
             if (unsupported.find(ukey) == unsupported.end())
             {
                 unsupported.emplace(std::move(ukey));
-                lg2::info("{CMD_NAME} not supported on {INTERFACE_NAME}",
-                          "CMD_NAME", cmdname, "INTERFACE_NAME", ifname);
+                lg2::info("{NET_IFREQ} not supported on {NET_INTF}",
+                          "NET_IFREQ", cmdname, "NET_INTF", ifname);
             }
             return ret;
         }
diff --git a/src/util.cpp b/src/util.cpp
index 87fe235..dbc474a 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -173,15 +173,17 @@
     else if (auto str = config.map.getLastValueString(section, key);
              str == nullptr)
     {
-        lg2::notice("Unable to get the value of {SECTION}[{KEY}] from {FILE}",
-                    "SECTION", section, "KEY", key, "FILE",
-                    config.getFilename());
+        lg2::notice(
+            "Unable to get the value of {CFG_SEC}[{CFG_KEY}] from {CFG_FILE}",
+            "CFG_SEC", section, "CFG_KEY", key, "CFG_FILE",
+            config.getFilename());
     }
     else if (auto val = fun(*str); !val)
     {
-        lg2::notice("Invalid value of {SECTION}[{KEY}] from {FILE}: {VALUE}",
-                    "SECTION", section, "KEY", key, "FILE",
-                    config.getFilename(), "VALUE", *str);
+        lg2::notice(
+            "Invalid value of {CFG_SEC}[{CFG_KEY}] from {CFG_FILE}: {CFG_VAL}",
+            "CFG_SEC", section, "CFG_KEY", key, "CFG_FILE",
+            config.getFilename(), "CFG_VAL", *str);
     }
     else
     {