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/actions/action.hpp b/control/json/actions/action.hpp
index 6cc5bac..a9cd49d 100644
--- a/control/json/actions/action.hpp
+++ b/control/json/actions/action.hpp
@@ -21,7 +21,7 @@
#include "group.hpp"
#include <nlohmann/json.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <algorithm>
#include <format>
@@ -35,7 +35,6 @@
{
using json = nlohmann::json;
-using namespace phosphor::logging;
/**
* @class ActionParseError - A parsing error exception
@@ -298,8 +297,7 @@
}
else
{
- log<level::ERR>(
- std::format("Action '{}' is already registered", name).c_str());
+ lg2::error("Action '{NAME}' is already registered", "NAME", name);
throw std::runtime_error("Actions with the same name found");
}
@@ -337,9 +335,9 @@
actions.begin()->first, [](auto list, auto act) {
return std::move(list) + ", " + act.first;
});
- log<level::ERR>(
- std::format("Action '{}' is not registered", name).c_str(),
- entry("AVAILABLE_ACTIONS=%s", acts.c_str()));
+ lg2::error(
+ "Action '{NAME}' is not registered. Available actions are {AVAILABLE_ACTIONS}",
+ "NAME", name, "AVAILABLE_ACTIONS", acts);
throw std::runtime_error("Unsupported action name given");
}
}