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/conditions.cpp b/monitor/conditions.cpp
index 62e272c..91d6a54 100644
--- a/monitor/conditions.cpp
+++ b/monitor/conditions.cpp
@@ -4,7 +4,7 @@
#include "types.hpp"
#include <nlohmann/json.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <algorithm>
@@ -38,9 +38,8 @@
if (!condParams.contains("properties"))
{
// Log error on missing required parameter
- log<level::ERR>(
- "Missing fan monitor condition properties",
- entry("NAME=%s", condParams["name"].get<std::string>().c_str()));
+ lg2::error("Missing fan monitor condition properties {NAME}", "NAME",
+ condParams["name"].get<std::string>());
throw std::runtime_error("Missing fan monitor condition properties");
}
std::vector<PropertyState> propStates;
@@ -50,9 +49,8 @@
!param.contains("property"))
{
// Log error on missing required parameters
- log<level::ERR>("Missing propertiesMatch condition parameters",
- entry("REQUIRED_PARAMETERS=%s",
- "{object, interface, property}"));
+ lg2::error(
+ "Missing properties. Match condition parameters 'object, interface, property'");
throw std::runtime_error(
"Missing propertiesMatch condition parameters");
}
@@ -61,9 +59,8 @@
if (!propAttrs.contains("name") || !propAttrs.contains("value"))
{
// Log error on missing required parameters
- log<level::ERR>(
- "Missing propertiesMatch condition property attributes",
- entry("REQUIRED_ATTRIBUTES=%s", "{name, value}"));
+ lg2::error(
+ "Missing properties. Match condition property attributes 'name, value'");
throw std::runtime_error(
"Missing propertiesMatch condition property attributes");
}