Move the monitor application to lg2
Update the logging API used for files in phosphor-fan-presence/monitor
from the older phosphor::logging::log to the more recent lg2::log.
Tested:
* Verified journal traces worked correctly in simulation.
* Modified json and simulation parameters to force various
application errors and verified correct output and key/value
pairs using journalctl.
Change-Id: Id6f5161edfd09b672aba8751a6d2c6518665188a
Signed-off-by: Anwaar Hadi <anwaar.hadi@ibm.com>
diff --git a/monitor/system.cpp b/monitor/system.cpp
index a4434dc..ff074c3 100644
--- a/monitor/system.cpp
+++ b/monitor/system.cpp
@@ -32,7 +32,7 @@
#include "hwmon_ffdc.hpp"
#include <nlohmann/json.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/bus/match.hpp>
#include <sdeventplus/event.hpp>
@@ -103,7 +103,7 @@
// Retrieve fan definitions and create fan objects to be monitored
setFans(fanDefs);
setFaultConfig(jsonObj);
- log<level::INFO>("Configuration loaded");
+ lg2::info("Configuration loaded");
_loaded = true;
#ifdef MONITOR_USE_JSON
@@ -235,8 +235,9 @@
}
catch (std::runtime_error& re)
{
- log<level::ERR>("Error reloading config, no config changes made",
- entry("LOAD_ERROR=%s", re.what()));
+ lg2::error(
+ "Error reloading config, no config changes made: {LOAD_ERROR}",
+ "LOAD_ERROR", re);
}
}
@@ -370,7 +371,7 @@
{
if (!_loaded)
{
- log<level::ERR>("No conf file found at power on");
+ lg2::error("No conf file found at power on");
throw std::runtime_error("No conf file found at power on");
}
@@ -591,7 +592,7 @@
std::ofstream file{System::dumpFile};
if (!file)
{
- log<level::ERR>("Could not open file for fan monitor dump");
+ lg2::error("Could not open file for fan monitor dump");
}
else
{