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/mapped_floor.cpp b/control/json/actions/mapped_floor.cpp
index 7cad6a4..8e1b222 100644
--- a/control/json/actions/mapped_floor.cpp
+++ b/control/json/actions/mapped_floor.cpp
@@ -21,6 +21,7 @@
#include "sdeventplus.hpp"
#include <nlohmann/json.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <algorithm>
#include <format>
@@ -41,10 +42,9 @@
auto newFloor = static_cast<T>(floor) + offset;
if (newFloor < 0)
{
- log<level::ERR>(
- std::format("{}: Floor offset of {} resulted in negative floor",
- actionName, offset)
- .c_str());
+ lg2::error(
+ "{ACTION_NAME}: Floor offset of {FLOOR_OFFSET} resulted in negative floor",
+ "ACTION_NAME", actionName, "FLOOR_OFFSET", offset);
return floor;
}
@@ -403,12 +403,11 @@
{
// If the parameter isn't there, then don't use
// this floor table
- log<level::DEBUG>(
- std::format("{}: Parameter {} specified in the JSON "
- "could not be found",
- ActionBase::getName(),
- std::get<std::string>(groupOrParameter))
- .c_str());
+ lg2::debug(
+ "{ACTION_NAME}: Parameter {PARAMETER} specified in the JSON "
+ "could not be found",
+ "ACTION_NAME", ActionBase::getName(), "PARAMETER",
+ std::get<std::string>(groupOrParameter));
continue;
}
}