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/triggers/timer.cpp b/control/json/triggers/timer.cpp
index 8acbc41..fd3aa10 100644
--- a/control/json/triggers/timer.cpp
+++ b/control/json/triggers/timer.cpp
@@ -20,23 +20,21 @@
#include "trigger_aliases.hpp"
#include <nlohmann/json.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <chrono>
-#include <format>
namespace phosphor::fan::control::json::trigger::timer
{
using json = nlohmann::json;
-using namespace phosphor::logging;
TimerType getType(const json& jsonObj)
{
if (!jsonObj.contains("type"))
{
- log<level::ERR>("Missing required timer trigger type",
- entry("JSON=%s", jsonObj.dump().c_str()));
+ lg2::error("Missing required timer trigger type", "JSON",
+ jsonObj.dump());
throw std::runtime_error("Missing required timer trigger type");
}
auto type = jsonObj["type"].get<std::string>();
@@ -50,10 +48,9 @@
}
else
{
- log<level::ERR>(
- std::format("Timer trigger type '{}' is not supported", type)
- .c_str(),
- entry("AVAILABLE_TYPES={oneshot, repeating}"));
+ lg2::error(
+ "Timer trigger type '{TYPE}' is not supported. Available types are 'oneshot, repeating'",
+ "TYPE", type);
throw std::runtime_error("Unsupported timer trigger type given");
}
}
@@ -62,8 +59,8 @@
{
if (!jsonObj.contains("interval"))
{
- log<level::ERR>("Missing required timer trigger interval",
- entry("JSON=%s", jsonObj.dump().c_str()));
+ lg2::error("Missing required timer trigger interval", "JSON",
+ jsonObj.dump());
throw std::runtime_error("Missing required timer trigger interval");
}
return static_cast<std::chrono::microseconds>(