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/sensor-monitor/alarm_timestamps.hpp b/sensor-monitor/alarm_timestamps.hpp
index b5889a9..5886dc4 100644
--- a/sensor-monitor/alarm_timestamps.hpp
+++ b/sensor-monitor/alarm_timestamps.hpp
@@ -22,12 +22,11 @@
#include <cereal/types/string.hpp>
#include <cereal/types/tuple.hpp>
#include <cereal/types/vector.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <sdeventplus/clock.hpp>
#include <sdeventplus/utility/timer.hpp>
#include <filesystem>
-#include <format>
#include <fstream>
#include <map>
#include <tuple>
@@ -242,13 +241,10 @@
catch (const std::exception& e)
{
// Include possible exception when removing file, otherwise ec = 0
- using namespace phosphor::logging;
std::error_code ec;
std::filesystem::remove(path, ec);
- log<level::ERR>(
- std::format("Unable to restore persisted times ({}, ec: {})",
- e.what(), ec.value())
- .c_str());
+ lg2::error("Unable to restore persisted times ({ERROR}, ec: {EC})",
+ "ERROR", e, "EC", ec.value());
}
}