Move the control application to lg2
Update the logging API used for files in phosphor-fan-presence/control
from the older phosphor::logging::log to the more recent lg2::log.
Tested:
* Verified journal traces worked correctly in simulation.
* Modified json to force various property errors and verified
correct key/value pairs in the journalctl output.
Change-Id: If1ac33b90abe2a9baae6f3cc788863bd514fa80e
Signed-off-by: Anwaar Hadi <anwaar.hadi@ibm.com>
diff --git a/control/json/utils/pcie_card_metadata.cpp b/control/json/utils/pcie_card_metadata.cpp
index 1e392af..392dee1 100644
--- a/control/json/utils/pcie_card_metadata.cpp
+++ b/control/json/utils/pcie_card_metadata.cpp
@@ -19,6 +19,8 @@
#include "json_config.hpp"
#include "utils/flight_recorder.hpp"
+#include <phosphor-logging/lg2.hpp>
+
#include <format>
#include <iostream>
@@ -80,9 +82,8 @@
FlightRecorder::instance().log(
"main", std::format("Configuration({}) loaded successfully",
confFile.string()));
- log<level::INFO>(std::format("Configuration({}) loaded successfully",
- confFile.string())
- .c_str());
+ lg2::info("Configuration({CONF_FILE}) loaded successfully", "CONF_FILE",
+ confFile);
}
}
@@ -154,9 +155,11 @@
uint16_t deviceID, uint16_t vendorID, uint16_t subsystemID,
uint16_t subsystemVendorID) const
{
- log<level::DEBUG>(std::format("Lookup {:#x} ${:#x} {:#x} {:#x}", deviceID,
- vendorID, subsystemID, subsystemVendorID)
- .c_str());
+ lg2::debug(
+ "Lookup {DEVICE_ID} ${VENDOR_ID} {SUBSYSTEM_ID} {SUBSYSTEM_VENDOR_ID}",
+ "DEVICE_ID", lg2::hex, deviceID, "VENDOR_ID", lg2::hex, vendorID,
+ "SUBSYSTEM_ID", lg2::hex, subsystemID, "SUBSYSTEM_VENDOR_ID", lg2::hex,
+ subsystemVendorID);
auto card = std::find_if(
_cards.begin(), _cards.end(),
[&deviceID, &vendorID, &subsystemID,