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/fan.cpp b/control/json/fan.cpp
index a808003..afbab79 100644
--- a/control/json/fan.cpp
+++ b/control/json/fan.cpp
@@ -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 <format>
@@ -27,7 +27,6 @@
{
using json = nlohmann::json;
-using namespace phosphor::logging;
constexpr auto FAN_SENSOR_PATH = "/xyz/openbmc_project/sensors/fan_tach/";
constexpr auto FAN_TARGET_PROPERTY = "Target";
@@ -44,8 +43,8 @@
{
if (!jsonObj.contains("target_interface"))
{
- log<level::ERR>("Missing required fan sensor target interface",
- entry("JSON=%s", jsonObj.dump().c_str()));
+ lg2::error("Missing required fan sensor target interface", "JSON",
+ jsonObj.dump());
throw std::runtime_error(
"Missing required fan sensor target interface");
}
@@ -56,8 +55,7 @@
{
if (!jsonObj.contains("sensors"))
{
- log<level::ERR>("Missing required fan sensors list",
- entry("JSON=%s", jsonObj.dump().c_str()));
+ lg2::error("Missing required fan sensors list", "JSON", jsonObj.dump());
throw std::runtime_error("Missing required fan sensors list");
}
std::string path;
@@ -91,8 +89,7 @@
{
if (!jsonObj.contains("zone"))
{
- log<level::ERR>("Missing required fan zone",
- entry("JSON=%s", jsonObj.dump().c_str()));
+ lg2::error("Missing required fan zone", "JSON", jsonObj.dump());
throw std::runtime_error("Missing required fan zone");
}
_zone = jsonObj["zone"].get<std::string>();