Updated Miscellaneous Journal Traces to lg2
Update the logging API used for files not in
phosphor-fan-presence/presence, phosphor-fan-presence/monitor,
or phosphor-fan-presence/control from the older phosphor::logging::log
to the more recent lg2::log.
Tested:
* Verified journal traces worked correctly in simulation and on
physical hardware.
* Modified json config files to force parsing and sensor-monitor
errors and verified correct output and key/value pairs in the
journalctl output.
Change-Id: Ie68ac5733ecd20d5f17882020df861a975121f77
Signed-off-by: Anwaar Hadi <anwaar.hadi@ibm.com>
diff --git a/json_config.hpp b/json_config.hpp
index 52dd505..87c6d1b 100644
--- a/json_config.hpp
+++ b/json_config.hpp
@@ -18,7 +18,7 @@
#include "sdbusplus.hpp"
#include <nlohmann/json.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus.hpp>
#include <sdeventplus/source/signal.hpp>
@@ -299,9 +299,8 @@
if (!confFile.empty() && fs::exists(confFile))
{
- log<level::INFO>(
- std::format("Loading configuration from {}", confFile.string())
- .c_str());
+ lg2::info("Loading configuration from {CONFFILE}", "CONFFILE",
+ confFile);
file.open(confFile);
try
{
@@ -310,11 +309,9 @@
}
catch (const std::exception& e)
{
- log<level::ERR>(
- std::format(
- "Failed to parse JSON config file: {}, error: {}",
- confFile.string(), e.what())
- .c_str());
+ lg2::error(
+ "Failed to parse JSON config file: {CONFFILE}, error: {ERROR}",
+ "CONFFILE", confFile, "ERROR", e);
throw std::runtime_error(
std::format(
"Failed to parse JSON config file: {}, error: {}",
@@ -324,9 +321,8 @@
}
else
{
- log<level::ERR>(std::format("Unable to open JSON config file: {}",
- confFile.string())
- .c_str());
+ lg2::error("Unable to open JSON config file: {CONFFILE}",
+ "CONFFILE", confFile);
throw std::runtime_error(
std::format("Unable to open JSON config file: {}",
confFile.string())