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");
}
}
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;
}
}
diff --git a/control/json/actions/net_target_decrease.cpp b/control/json/actions/net_target_decrease.cpp
index a9fe8d1..9d423de 100644
--- a/control/json/actions/net_target_decrease.cpp
+++ b/control/json/actions/net_target_decrease.cpp
@@ -21,17 +21,15 @@
#include "group.hpp"
#include <nlohmann/json.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <algorithm>
-#include <format>
#include <variant>
namespace phosphor::fan::control::json
{
using json = nlohmann::json;
-using namespace phosphor::logging;
NetTargetDecrease::NetTargetDecrease(const json& jsonObj,
const std::vector<Group>& groups) :
@@ -122,12 +120,12 @@
else
{
// Unsupported group member type for this action
- log<level::ERR>(
- std::format("Action {}: Unsupported group member type "
- "given. [object = {} : {} : {}]",
- ActionBase::getName(), member,
- group.getInterface(), group.getProperty())
- .c_str());
+ lg2::error(
+ "Action {ACTION_NAME}: Unsupported group member type "
+ "given. [object = {MEMBER} : {GROUP_INTERFACE} : {GROUP_PROPERTY}]",
+ "ACTION_NAME", ActionBase::getName(), "MEMBER", member,
+ "GROUP_INTERFACE", group.getInterface(),
+ "GROUP_PROPERTY", group.getProperty());
}
}
catch (const std::out_of_range& oore)
diff --git a/control/json/actions/net_target_increase.cpp b/control/json/actions/net_target_increase.cpp
index 9c712a7..08a9a1c 100644
--- a/control/json/actions/net_target_increase.cpp
+++ b/control/json/actions/net_target_increase.cpp
@@ -21,17 +21,15 @@
#include "group.hpp"
#include <nlohmann/json.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <algorithm>
-#include <format>
#include <variant>
namespace phosphor::fan::control::json
{
using json = nlohmann::json;
-using namespace phosphor::logging;
NetTargetIncrease::NetTargetIncrease(const json& jsonObj,
const std::vector<Group>& groups) :
@@ -117,13 +115,12 @@
else
{
// Unsupported group member type for this action
- log<level::ERR>(
- std::format(
- "Action {}: Unsupported group member type "
- "given. [object = {} : {} : {}]",
- ActionBase::getName(), member,
- group.getInterface(), group.getProperty())
- .c_str());
+ lg2::error(
+ "Action {ACTION_NAME}: Unsupported group member type "
+ "given. [object = {MEMBER} : {GROUP_INTERFACE} : {GROUP_PROPERTY}]",
+ "ACTION_NAME", ActionBase::getName(), "MEMBER",
+ member, "GROUP_INTERFACE", group.getInterface(),
+ "GROUP_PROPERTY", group.getProperty());
}
}
catch (const std::out_of_range& oore)
diff --git a/control/json/actions/pcie_card_floors.cpp b/control/json/actions/pcie_card_floors.cpp
index a5cfee5..33cedfb 100644
--- a/control/json/actions/pcie_card_floors.cpp
+++ b/control/json/actions/pcie_card_floors.cpp
@@ -20,6 +20,8 @@
#include "sdbusplus.hpp"
#include "sdeventplus.hpp"
+#include <phosphor-logging/lg2.hpp>
+
namespace phosphor::fan::control::json
{
@@ -66,10 +68,9 @@
{
if (group.getInterface() != powerStateIface)
{
- log<level::DEBUG>(
- std::format("Wrong interface {} in PCIe card floor group",
- group.getInterface())
- .c_str());
+ lg2::debug(
+ "Wrong interface {GROUP_INTERFACE} in PCIe card floor group",
+ "GROUP_INTERFACE", group.getInterface());
continue;
}
@@ -84,9 +85,8 @@
}
catch (const std::out_of_range& oore)
{
- log<level::ERR>(
- std::format("Could not get power state for {}", slotPath)
- .c_str());
+ lg2::error("Could not get power state for {SLOT_PATH}",
+ "SLOT_PATH", slotPath);
continue;
}
@@ -187,11 +187,10 @@
}
catch (const std::out_of_range& oore)
{
- log<level::ERR>(
- std::format(
- "{}: Could not get PCIeDevice property {} {} from cache ",
- ActionBase::getName(), objectPath, propertyName)
- .c_str());
+ lg2::error(
+ "{ACTION_NAME}: Could not get PCIeDevice property {OBJECT_PATH} {PROPERTY_NAME} from cache ",
+ "ACTION_NAME", ActionBase::getName(), "OBJECT_PATH", objectPath,
+ "PROPERTY_NAME", propertyName);
throw;
}
@@ -202,11 +201,11 @@
}
catch (const std::invalid_argument& e)
{
- log<level::INFO>(
- std::format("{}: {} has invalid PCIeDevice property {} value: {}",
- ActionBase::getName(), objectPath, propertyName,
- std::get<std::string>(variantValue))
- .c_str());
+ lg2::info(
+ "{ACTION_NAME}: {OBJECT_PATH} has invalid PCIeDevice property {PROPERTY_NAME} value: {VALUE}",
+ "ACTION_NAME", ActionBase::getName(), "OBJECT_PATH", objectPath,
+ "PROPERTY_NAME", propertyName, "VALUE",
+ std::get<std::string>(variantValue));
throw;
}
}
diff --git a/control/json/actions/request_target_base.cpp b/control/json/actions/request_target_base.cpp
index f52a19b..186e611 100644
--- a/control/json/actions/request_target_base.cpp
+++ b/control/json/actions/request_target_base.cpp
@@ -20,16 +20,14 @@
#include "group.hpp"
#include <nlohmann/json.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <algorithm>
-#include <format>
namespace phosphor::fan::control::json
{
using json = nlohmann::json;
-using namespace phosphor::logging;
RequestTargetBase::RequestTargetBase(const json& jsonObj,
const std::vector<Group>& groups) :
@@ -73,12 +71,12 @@
else
{
// Unsupported group member type for this action
- log<level::ERR>(
- std::format("Action {}: Unsupported group member type "
- "given. [object = {} : {} : {}]",
- getName(), member, group.getInterface(),
- group.getProperty())
- .c_str());
+ lg2::error(
+ "Action {ACTION_NAME}: Unsupported group member type "
+ "given. [object = {MEMBER} : {GROUP_INTERFACE} : {GROUP_PROPERTY}]",
+ "ACTION_NAME", getName(), "MEMBER", member,
+ "GROUP_INTERFACE", group.getInterface(),
+ "GROUP_PROPERTY", group.getProperty());
}
}
catch (const std::out_of_range& oore)
diff --git a/control/json/actions/set_parameter_from_group_max.cpp b/control/json/actions/set_parameter_from_group_max.cpp
index 811f37c..e019e7c 100644
--- a/control/json/actions/set_parameter_from_group_max.cpp
+++ b/control/json/actions/set_parameter_from_group_max.cpp
@@ -17,13 +17,12 @@
#include "../manager.hpp"
-#include <format>
+#include <phosphor-logging/lg2.hpp>
namespace phosphor::fan::control::json
{
using json = nlohmann::json;
-using namespace phosphor::logging;
SetParameterFromGroupMax::SetParameterFromGroupMax(
const json& jsonObj, const std::vector<Group>& groups) :
@@ -69,12 +68,12 @@
!std::is_same_v<int32_t, V> &&
!std::is_same_v<int64_t, V>)
{
- log<level::ERR>(std::format("{}: Group {} has more "
- "than one member but "
- "isn't numeric",
- ActionBase::getName(),
- group.getName())
- .c_str());
+ lg2::error(
+ "{ACTION_NAME}: Group {GROUP_NAME} has more "
+ "than one member but "
+ "isn't numeric",
+ "ACTION_NAME", ActionBase::getName(),
+ "GROUP_NAME", group.getName());
invalid = true;
}
},
@@ -104,10 +103,9 @@
}
catch (const std::exception& e)
{
- log<level::ERR>(
- std::format("{}: Could not perform modifier operation: {}",
- ActionBase::getName(), e.what())
- .c_str());
+ lg2::error(
+ "{ACTION_NAME}: Could not perform modifier operation: {ERROR}",
+ "ACTION_NAME", ActionBase::getName(), "ERROR", e);
return;
}
}
diff --git a/control/json/actions/target_from_group_max.cpp b/control/json/actions/target_from_group_max.cpp
index d92457d..c4a0427 100644
--- a/control/json/actions/target_from_group_max.cpp
+++ b/control/json/actions/target_from_group_max.cpp
@@ -17,7 +17,8 @@
#include "../manager.hpp"
-#include <format>
+#include <phosphor-logging/lg2.hpp>
+
#include <iostream>
namespace phosphor::fan::control::json
@@ -27,7 +28,6 @@
size_t TargetFromGroupMax::_groupIndexCounter = 0;
using json = nlohmann::json;
-using namespace phosphor::logging;
TargetFromGroupMax::TargetFromGroupMax(const json& jsonObj,
const std::vector<Group>& groups) :
@@ -190,11 +190,10 @@
!std::is_same_v<int32_t, V> &&
!std::is_same_v<int64_t, V>)
{
- log<level::ERR>(
- std::format("{}: Group {}'s member "
- "isn't numeric",
- ActionBase::getName(), group.getName())
- .c_str());
+ lg2::error("{ACTION_NAME}: Group {GROUP_NAME}'s member "
+ "isn't numeric",
+ "ACTION_NAME", ActionBase::getName(),
+ "GROUP_NAME", group.getName());
invalid = true;
}
},
diff --git a/control/json/config_base.hpp b/control/json/config_base.hpp
index a7b47b8..c521c9f 100644
--- a/control/json/config_base.hpp
+++ b/control/json/config_base.hpp
@@ -16,7 +16,7 @@
#pragma once
#include <nlohmann/json.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <vector>
@@ -24,7 +24,6 @@
{
using json = nlohmann::json;
-using namespace phosphor::logging;
using PropertyVariantType =
std::variant<bool, int32_t, int64_t, double, std::string>;
@@ -135,10 +134,9 @@
return *stringPtr;
}
- log<level::ERR>(
- "Unsupported data type for JSON object's value",
- entry("JSON_ENTRY=%s", object.dump().c_str()),
- entry("SUPPORTED_TYPES=%s", "{bool, int, double, string}"));
+ lg2::error(
+ "Unsupported data type for JSON object's value. Supported Types are 'bool, int, double, string'",
+ "JSON_ENTRY", object.dump());
throw std::runtime_error(
"Unsupported data type for JSON object's value");
}
@@ -165,8 +163,8 @@
if (!jsonObj.contains("name"))
{
// Log error on missing configuration object's name
- log<level::ERR>("Missing required configuration object's name",
- entry("JSON=%s", jsonObj.dump().c_str()));
+ lg2::error("Missing required configuration object's name", "JSON",
+ jsonObj.dump());
throw std::runtime_error(
"Missing required configuration object's name");
}
diff --git a/control/json/dbus_zone.cpp b/control/json/dbus_zone.cpp
index a8cbe01..c1cf891 100644
--- a/control/json/dbus_zone.cpp
+++ b/control/json/dbus_zone.cpp
@@ -23,17 +23,15 @@
#include <cereal/archives/json.hpp>
#include <cereal/cereal.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <algorithm>
#include <filesystem>
-#include <format>
#include <fstream>
namespace phosphor::fan::control::json
{
-using namespace phosphor::logging;
namespace fs = std::filesystem;
DBusZone::DBusZone(const Zone& zone) :
@@ -90,11 +88,9 @@
// Include possible exception when removing file, otherwise ec = 0
std::error_code ec;
fs::remove(path, ec);
- log<level::ERR>(
- std::format("Unable to restore persisted `Current` thermal mode "
- "property ({}, ec: {})",
- e.what(), ec.value())
- .c_str());
+ lg2::error("Unable to restore persisted `Current` thermal mode "
+ "property ({ERROR}, ec: {ERROR_CODE})",
+ "ERROR", e, "ERROR_CODE", ec.value());
current = ThermalModeIntf::current();
}
diff --git a/control/json/event.cpp b/control/json/event.cpp
index fa3502d..e4c9f8e 100644
--- a/control/json/event.cpp
+++ b/control/json/event.cpp
@@ -23,18 +23,16 @@
#include "trigger.hpp"
#include <nlohmann/json.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus.hpp>
#include <algorithm>
-#include <format>
#include <optional>
namespace phosphor::fan::control::json
{
using json = nlohmann::json;
-using namespace phosphor::logging;
std::map<configKey, std::unique_ptr<Group>> Event::allGroups;
@@ -106,8 +104,7 @@
if (!jsonObj.contains("interface") || !jsonObj.contains("property") ||
!jsonObj["property"].contains("name"))
{
- log<level::ERR>("Missing required group attribute",
- entry("JSON=%s", jsonObj.dump().c_str()));
+ lg2::error("Missing required group attribute", "JSON", jsonObj.dump());
throw std::runtime_error("Missing required group attribute");
}
@@ -147,10 +144,10 @@
{
if (!jsonGrp.contains("name"))
{
- auto msg = std::format("Missing required group name attribute");
- log<level::ERR>(msg.c_str(),
- entry("JSON=%s", jsonGrp.dump().c_str()));
- throw std::runtime_error(msg.c_str());
+ lg2::error("Missing required group name attribute", "JSON",
+ jsonGrp.dump());
+ throw std::runtime_error(
+ "Missing required group name attribute");
}
configKey eventProfile =
@@ -176,8 +173,8 @@
{
if (!jsonAct.contains("name"))
{
- log<level::ERR>("Missing required event action name",
- entry("JSON=%s", jsonAct.dump().c_str()));
+ lg2::error("Missing required event action name", "JSON",
+ jsonAct.dump());
throw std::runtime_error("Missing required event action name");
}
@@ -223,11 +220,11 @@
}
if (actionZones.empty())
{
- log<level::DEBUG>(
- std::format("No zones configured for event {}'s action {} "
- "based on the active profile(s)",
- getName(), jsonAct["name"].get<std::string>())
- .c_str());
+ lg2::debug(
+ "No zones configured for event {EVENT_NAME}'s action {ACTION} "
+ "based on the active profile(s)",
+ "EVENT_NAME", getName(), "ACTION",
+ jsonAct["name"].get<std::string>());
}
// Action specific groups, if any given, will override the use of event
@@ -261,11 +258,11 @@
if (actionGroups.empty() && _groups.empty())
{
- log<level::DEBUG>(
- std::format("No groups configured for event {}'s action {} "
- "based on the active profile(s)",
- getName(), jsonAct["name"].get<std::string>())
- .c_str());
+ lg2::debug(
+ "No groups configured for event {EVENT_NAME}'s action {ACTION} "
+ "based on the active profile(s)",
+ "EVENT_NAME", getName(), "ACTION",
+ jsonAct["name"].get<std::string>());
}
}
}
@@ -274,16 +271,16 @@
{
if (!jsonObj.contains("triggers"))
{
- log<level::ERR>("Missing required event triggers list",
- entry("JSON=%s", jsonObj.dump().c_str()));
+ lg2::error("Missing required event triggers list", "JSON",
+ jsonObj.dump());
throw std::runtime_error("Missing required event triggers list");
}
for (const auto& jsonTrig : jsonObj["triggers"])
{
if (!jsonTrig.contains("class"))
{
- log<level::ERR>("Missing required event trigger class",
- entry("JSON=%s", jsonTrig.dump().c_str()));
+ lg2::error("Missing required event trigger class", "JSON",
+ jsonTrig.dump());
throw std::runtime_error("Missing required event trigger class");
}
// The class of trigger used to run the event actions
@@ -304,9 +301,9 @@
trigger::triggers.begin()->first, [](auto list, auto trig) {
return std::move(list) + ", " + trig.first;
});
- log<level::ERR>(
- std::format("Trigger '{}' is not recognized", tClass).c_str(),
- entry("AVAILABLE_TRIGGERS=%s", availTrigs.c_str()));
+ lg2::error(
+ "Trigger '{TRIGGER}' is not recognized. Available triggers are {AVAILABLE_TRIGGERS}",
+ "TRIGGER", tClass, "AVAILABLE_TRIGGERS", availTrigs);
throw std::runtime_error("Unsupported trigger class name given");
}
}
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>();
diff --git a/control/json/group.cpp b/control/json/group.cpp
index e100d71..8ae5b9d 100644
--- a/control/json/group.cpp
+++ b/control/json/group.cpp
@@ -16,13 +16,12 @@
#include "group.hpp"
#include <nlohmann/json.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
namespace phosphor::fan::control::json
{
using json = nlohmann::json;
-using namespace phosphor::logging;
std::set<std::string> Group::_allMembers{};
@@ -51,8 +50,7 @@
{
if (!jsonObj.contains("members"))
{
- log<level::ERR>("Missing required group's members",
- entry("JSON=%s", jsonObj.dump().c_str()));
+ lg2::error("Missing required group's members", "JSON", jsonObj.dump());
throw std::runtime_error("Missing required group's members");
}
for (const auto& member : jsonObj["members"])
diff --git a/control/json/manager.cpp b/control/json/manager.cpp
index a74b1b8..99b87da 100644
--- a/control/json/manager.cpp
+++ b/control/json/manager.cpp
@@ -94,8 +94,8 @@
_loadAllowed = false;
_profiles.swap(profiles);
_activeProfiles.swap(activeProfiles);
- log<level::ERR>("Error reloading configs, no changes made",
- entry("LOAD_ERROR=%s", re.what()));
+ lg2::error("Error reloading configs, no changes made: {LOAD_ERROR}",
+ "LOAD_ERROR", re);
FlightRecorder::instance().log(
"main", std::format("Error reloading configs, no changes made: {}",
re.what()));
@@ -116,7 +116,7 @@
std::ofstream file{Manager::dumpFile};
if (!file)
{
- log<level::ERR>("Could not open file for fan dump");
+ lg2::error("Could not open file for fan dump");
return;
}
@@ -541,11 +541,9 @@
if (service.empty())
{
// Log service not found for object
- log<level::DEBUG>(
- std::format(
- "Unable to get service name for path {}, interface {}",
- path, intf)
- .c_str());
+ lg2::debug(
+ "Unable to get service name for path {PATH}, interface {INTERFACE}",
+ "PATH", path, "INTERFACE", intf);
return;
}
}
diff --git a/control/json/manager.hpp b/control/json/manager.hpp
index 5d94623..7e5d496 100644
--- a/control/json/manager.hpp
+++ b/control/json/manager.hpp
@@ -26,7 +26,7 @@
#include "zone.hpp"
#include <nlohmann/json.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/manager.hpp>
#include <sdeventplus/event.hpp>
@@ -46,7 +46,6 @@
{
using json = nlohmann::json;
-using namespace phosphor::logging;
/* Application name to be appended to the path for loading a JSON config file */
constexpr auto confAppName = "control";
@@ -242,10 +241,8 @@
std::make_pair(obj->getName(), obj->getProfiles()),
std::move(obj));
}
- log<level::INFO>(
- std::format("Configuration({}) loaded successfully",
- T::confFileName)
- .c_str());
+ lg2::info("Configuration({CONF_FILE}) loaded successfully",
+ "CONF_FILE", T::confFileName);
FlightRecorder::instance().log(
"main", std::format("Configuration({}) loaded successfully",
T::confFileName));
diff --git a/control/json/profile.cpp b/control/json/profile.cpp
index 0778820..c56307f 100644
--- a/control/json/profile.cpp
+++ b/control/json/profile.cpp
@@ -18,7 +18,7 @@
#include "sdbusplus.hpp"
#include <nlohmann/json.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <algorithm>
#include <iterator>
@@ -28,7 +28,6 @@
{
using json = nlohmann::json;
-using namespace phosphor::logging;
// String key must be in all lowercase for method lookup
const std::map<std::string, methodHandler> Profile::_methods = {
@@ -44,8 +43,7 @@
if (!jsonObj.contains("method") || !jsonObj["method"].contains("name"))
{
// Log error on missing profile method
- log<level::ERR>("Missing required profile method",
- entry("JSON=%s", jsonObj.dump().c_str()));
+ lg2::error("Missing required profile method", "JSON", jsonObj.dump());
throw std::runtime_error("Missing required profile method");
}
// The method to use in determining if the profile is active
@@ -65,9 +63,9 @@
_methods.begin()->first, [](auto list, auto method) {
return std::move(list) + ", " + method.first;
});
- log<level::ERR>("Configured method not available",
- entry("JSON=%s", jsonObj["method"].dump().c_str()),
- entry("METHODS_AVAILABLE=%s", methods.c_str()));
+ lg2::error(
+ "Configured method not available. Available methods are {METHODS_AVAILABLE}",
+ "METHODS_AVAILABLE", methods, "JSON", jsonObj["method"].dump());
}
}
@@ -75,8 +73,8 @@
{
if (!method.contains("properties"))
{
- log<level::ERR>("Missing required all_of method properties list",
- entry("JSON=%s", method.dump().c_str()));
+ lg2::error("Missing required all_of method properties list", "JSON",
+ method.dump());
throw std::runtime_error(
"Missing required all_of method properties list");
}
@@ -87,9 +85,8 @@
if (!obj.contains("path") || !obj.contains("interface") ||
!obj.contains("property") || !obj.contains("value"))
{
- log<level::ERR>(
- "Missing required all_of method property parameters",
- entry("JSON=%s", obj.dump().c_str()));
+ lg2::error("Missing required all_of method property parameters",
+ "JSON", obj.dump());
throw std::runtime_error(
"Missing required all_of method parameters");
}
diff --git a/control/json/triggers/init.cpp b/control/json/triggers/init.cpp
index 3d9a535..4d24c93 100644
--- a/control/json/triggers/init.cpp
+++ b/control/json/triggers/init.cpp
@@ -22,10 +22,9 @@
#include "trigger_aliases.hpp"
#include <nlohmann/json.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <algorithm>
-#include <format>
#include <iterator>
#include <memory>
#include <numeric>
@@ -36,7 +35,6 @@
{
using json = nlohmann::json;
-using namespace phosphor::logging;
void getProperties(Manager* mgr, const Group& group)
{
@@ -107,11 +105,9 @@
// Path and/or interface configured does not exist on dbus?
// TODO How to handle this? Create timer to keep checking for
// object/service to appear? When to stop checking?
- log<level::ERR>(
- std::format(
- "Unable to get service name for path {}, interface {}",
- member, intf)
- .c_str());
+ lg2::error(
+ "Unable to get service name for path {MEMBER}, interface {GROUP_INTERFACE}",
+ "MEMBER", member, "GROUP_INTERFACE", intf);
}
}
catch (const util::DBusMethodError& dme)
@@ -127,10 +123,11 @@
// Path and/or interface configured does not exist on dbus?
// TODO How to handle this? Create timer to keep checking for
// object/service to appear? When to stop checking?
- log<level::ERR>(std::format("Unable to get service({}) owner "
- "state for path {}, interface {}",
- servName, member, intf)
- .c_str());
+ lg2::error(
+ "Unable to get service({SERVICE}) owner "
+ "state for path {MEMBER}, interface {GROUP_INTERFACE}",
+ "SERVICE", servName, "MEMBER", member, "GROUP_INTERFACE",
+ intf);
throw dme;
}
}
@@ -164,12 +161,12 @@
methods.begin()->first, [](auto list, auto method) {
return std::move(list) + ", " + method.first;
});
- auto msg =
- std::format("Event '{}' requires a supported method given to "
- "be init driven, available methods: {}",
- eventName, availMethods);
- log<level::ERR>(msg.c_str());
- throw std::runtime_error(msg.c_str());
+ lg2::error(
+ "Event '{EVENT_NAME}' requires a supported method given to "
+ "be init driven, available methods: {AVAILABLE_METHODS}",
+ "EVENT_NAME", eventName, "AVAILABLE_METHODS", availMethods);
+ throw std::runtime_error(
+ "Event requires a supported method given to be init driven");
}
for (const auto& group : groups)
diff --git a/control/json/triggers/parameter.cpp b/control/json/triggers/parameter.cpp
index 1bec051..5a2d59f 100644
--- a/control/json/triggers/parameter.cpp
+++ b/control/json/triggers/parameter.cpp
@@ -17,7 +17,7 @@
#include "../manager.hpp"
-#include <format>
+#include <phosphor-logging/lg2.hpp>
namespace phosphor::fan::control::json::trigger::parameter
{
@@ -30,10 +30,11 @@
{
if (!jsonObj.contains("parameter"))
{
- auto msg = std::format(
- "Event '{}' parameter trigger is missing 'parameter'", eventName);
- log<level::ERR>(msg.c_str());
- throw std::runtime_error(msg);
+ lg2::error(
+ "Event '{EVENT_NAME}' parameter trigger is missing 'parameter'",
+ "EVENT_NAME", eventName);
+ throw std::runtime_error(
+ "Event parameter trigger is missing 'parameter'");
}
auto name = jsonObj["parameter"].get<std::string>();
diff --git a/control/json/triggers/signal.cpp b/control/json/triggers/signal.cpp
index 39c20b1..d623616 100644
--- a/control/json/triggers/signal.cpp
+++ b/control/json/triggers/signal.cpp
@@ -22,11 +22,10 @@
#include "trigger_aliases.hpp"
#include <nlohmann/json.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus/match.hpp>
#include <algorithm>
-#include <format>
#include <functional>
#include <iterator>
#include <memory>
@@ -38,7 +37,6 @@
{
using json = nlohmann::json;
-using namespace phosphor::logging;
using namespace sdbusplus::bus::match;
void subscribe(const std::string& match, SignalPkg&& signalPkg,
@@ -204,11 +202,10 @@
// Path and/or interface configured does not exist on dbus yet?
// TODO How to handle this? Create timer to keep checking for
// service to appear? When to stop checking?
- log<level::ERR>(
- std::format("Events will not be triggered by name owner changed"
- "signals from service of path {}, interface {}",
- member, group.getInterface())
- .c_str());
+ lg2::error(
+ "Events will not be triggered by name owner changed"
+ "signals from service of path {MEMBER}, interface {GROUP_INTERFACE}",
+ "MEMBER", member, "GROUP_INTERFACE", group.getInterface());
}
}
}
@@ -254,12 +251,12 @@
signals.begin()->first, [](auto list, auto signal) {
return std::move(list) + ", " + signal.first;
});
- auto msg =
- std::format("Event '{}' requires a supported signal given to be "
- "triggered by signal, available signals: {}",
- eventName, availSignals);
- log<level::ERR>(msg.c_str());
- throw std::runtime_error(msg.c_str());
+ lg2::error(
+ "Event '{EVENT_NAME}' requires a supported signal given to be "
+ "triggered by signal, available signals: {AVAILABLE_SIGNALS}",
+ "EVENT_NAME", eventName, "AVAILABLE_SIGNALS", availSignals);
+ throw std::runtime_error(
+ "Event requires a supported signal given to be triggered by signal.");
}
return [subscriber = std::move(subscriber),
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>(
diff --git a/control/json/utils/modifier.cpp b/control/json/utils/modifier.cpp
index 0b4adfd..c19aca1 100644
--- a/control/json/utils/modifier.cpp
+++ b/control/json/utils/modifier.cpp
@@ -19,11 +19,7 @@
#include "json/config_base.hpp"
#include "json/manager.hpp"
-#include <phosphor-logging/log.hpp>
-
-#include <format>
-
-using namespace phosphor::logging;
+#include <phosphor-logging/lg2.hpp>
namespace phosphor::fan::control::json
{
@@ -167,10 +163,8 @@
const auto& valueArray = jsonObj["value"];
if (!valueArray.is_array())
{
- log<level::ERR>(
- std::format("Invalid JSON data for less_than config: {}",
- valueArray.dump())
- .c_str());
+ lg2::error("Invalid JSON data for less_than config: {VALUE_ARRAY}",
+ "VALUE_ARRAY", valueArray.dump());
throw std::invalid_argument("Invalid modifier JSON");
}
@@ -179,11 +173,9 @@
if (!valueEntry.contains("arg_value") ||
!valueEntry.contains("parameter_value"))
{
- log<level::ERR>(
- std::format("Missing arg_value or parameter_value keys "
- "in less_than config: {}",
- valueArray.dump())
- .c_str());
+ lg2::error("Missing arg_value or parameter_value keys "
+ "in less_than config: {VALUE_ARRAY}",
+ "VALUE_ARRAY", valueArray.dump());
throw std::invalid_argument("Invalid modifier JSON");
}
@@ -191,12 +183,10 @@
if (std::holds_alternative<bool>(argVal))
{
- log<level::ERR>(
- std::format(
- "Invalid data type in arg_value key in modifier JSON "
- "config: {}",
- valueArray.dump())
- .c_str());
+ lg2::error(
+ "Invalid data type in arg_value key in modifier JSON "
+ "config: {VALUE_ARRAY}",
+ "VALUE_ARRAY", valueArray.dump());
throw std::invalid_argument("Invalid modifier JSON");
}
@@ -208,10 +198,9 @@
if (rangeValues.empty())
{
- log<level::ERR>(std::format("No valid range values found in "
- "modifier json: {}",
- valueArray.dump())
- .c_str());
+ lg2::error("No valid range values found in "
+ "modifier json: {VALUE_ARRAY}",
+ "VALUE_ARRAY", valueArray.dump());
throw std::invalid_argument("Invalid modifier JSON");
}
@@ -291,11 +280,9 @@
{
if (!jsonObj.contains("operator") || !jsonObj.contains("value"))
{
- log<level::ERR>(
- std::format(
- "Modifier entry in JSON missing 'operator' or 'value': {}",
- jsonObj.dump())
- .c_str());
+ lg2::error(
+ "Modifier entry in JSON missing 'operator' or 'value': {JSON_OBJECT}",
+ "JSON_OBJECT", jsonObj.dump());
throw std::invalid_argument("Invalid modifier JSON");
}
@@ -311,9 +298,8 @@
}
else
{
- log<level::ERR>(std::format("Invalid operator in the modifier JSON: {}",
- jsonObj.dump())
- .c_str());
+ lg2::error("Invalid operator in the modifier JSON: {JSON_OBJECT}",
+ "JSON_OBJECT", jsonObj.dump());
throw std::invalid_argument("Invalid operator in the modifier JSON");
}
}
diff --git a/control/json/utils/pcie_card_metadata.cpp b/control/json/utils/pcie_card_metadata.cpp
index 1e392af..392dee1 100644
--- a/control/json/utils/pcie_card_metadata.cpp
+++ b/control/json/utils/pcie_card_metadata.cpp
@@ -19,6 +19,8 @@
#include "json_config.hpp"
#include "utils/flight_recorder.hpp"
+#include <phosphor-logging/lg2.hpp>
+
#include <format>
#include <iostream>
@@ -80,9 +82,8 @@
FlightRecorder::instance().log(
"main", std::format("Configuration({}) loaded successfully",
confFile.string()));
- log<level::INFO>(std::format("Configuration({}) loaded successfully",
- confFile.string())
- .c_str());
+ lg2::info("Configuration({CONF_FILE}) loaded successfully", "CONF_FILE",
+ confFile);
}
}
@@ -154,9 +155,11 @@
uint16_t deviceID, uint16_t vendorID, uint16_t subsystemID,
uint16_t subsystemVendorID) const
{
- log<level::DEBUG>(std::format("Lookup {:#x} ${:#x} {:#x} {:#x}", deviceID,
- vendorID, subsystemID, subsystemVendorID)
- .c_str());
+ lg2::debug(
+ "Lookup {DEVICE_ID} ${VENDOR_ID} {SUBSYSTEM_ID} {SUBSYSTEM_VENDOR_ID}",
+ "DEVICE_ID", lg2::hex, deviceID, "VENDOR_ID", lg2::hex, vendorID,
+ "SUBSYSTEM_ID", lg2::hex, subsystemID, "SUBSYSTEM_VENDOR_ID", lg2::hex,
+ subsystemVendorID);
auto card = std::find_if(
_cards.begin(), _cards.end(),
[&deviceID, &vendorID, &subsystemID,
diff --git a/control/json/zone.cpp b/control/json/zone.cpp
index ca78900..170b53d 100644
--- a/control/json/zone.cpp
+++ b/control/json/zone.cpp
@@ -21,11 +21,12 @@
#include "sdbusplus.hpp"
#include <nlohmann/json.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <sdeventplus/event.hpp>
#include <algorithm>
#include <chrono>
+#include <format>
#include <iterator>
#include <map>
#include <memory>
@@ -37,7 +38,6 @@
{
using json = nlohmann::json;
-using namespace phosphor::logging;
const std::map<
std::string,
@@ -80,11 +80,10 @@
_defaultFloor = jsonObj["default_floor"].get<uint64_t>();
if (_defaultFloor > _ceiling)
{
- log<level::ERR>(
- std::format("Configured default_floor({}) above ceiling({}), "
- "setting default floor to ceiling",
- _defaultFloor, _ceiling)
- .c_str());
+ lg2::error(
+ "Configured default_floor({DEFAULT_FLOOR}) above ceiling({CEILING}), "
+ "setting default floor to ceiling",
+ "DEFAULT_FLOOR", _defaultFloor, "CEILING", _ceiling);
_defaultFloor = _ceiling;
}
// Start with the current floor set as the default
@@ -172,10 +171,9 @@
}
else
{
- log<level::DEBUG>(
- std::format("Configured fan {} not found in zone {} to lock target",
- fname, getName())
- .c_str());
+ lg2::debug(
+ "Configured fan {FAN} not found in zone {ZONE_NAME} to lock target",
+ "FAN", fname, "ZONE_NAME", getName());
}
}
@@ -195,11 +193,9 @@
}
else
{
- log<level::DEBUG>(
- std::format(
- "Configured fan {} not found in zone {} to unlock target",
- fname, getName())
- .c_str());
+ lg2::debug(
+ "Configured fan {FAN} not found in zone {ZONE_NAME} to unlock target",
+ "FAN", fname, "ZONE_NAME", getName());
}
}
@@ -437,9 +433,9 @@
{
if (!jsonObj.contains("poweron_target"))
{
- auto msg = "Missing required zone's poweron target";
- log<level::ERR>(msg, entry("JSON=%s", jsonObj.dump().c_str()));
- throw std::runtime_error(msg);
+ lg2::error("Missing required zone's poweron target", "JSON",
+ jsonObj.dump());
+ throw std::runtime_error("Missing required zone's poweron target");
}
_poweronTarget = jsonObj["poweron_target"].get<uint64_t>();
}
@@ -450,8 +446,9 @@
{
if (!interface.contains("name") || !interface.contains("properties"))
{
- log<level::ERR>("Missing required zone interface attributes",
- entry("JSON=%s", interface.dump().c_str()));
+ lg2::error(
+ "Missing required zone interface attributes 'name, properties'",
+ "JSON", interface.dump());
throw std::runtime_error(
"Missing required zone interface attributes");
}
@@ -465,9 +462,9 @@
_intfPropHandlers.begin()->first, [](auto list, auto intf) {
return std::move(list) + ", " + intf.first;
});
- log<level::ERR>("Configured interface not available",
- entry("JSON=%s", interface.dump().c_str()),
- entry("AVAILABLE_INTFS=%s", intfs.c_str()));
+ lg2::error(
+ "Configured interface not available. Available interfaces are {AVAILABLE_INTFS}",
+ "JSON", interface.dump(), "AVAILABLE_INTFS", intfs);
throw std::runtime_error("Configured interface not available");
}
@@ -475,9 +472,9 @@
{
if (!property.contains("name"))
{
- log<level::ERR>(
- "Missing required interface property attributes",
- entry("JSON=%s", property.dump().c_str()));
+ lg2::error(
+ "Missing required interface property attributes 'name'",
+ "JSON", property.dump());
throw std::runtime_error(
"Missing required interface property attributes");
}
@@ -500,9 +497,9 @@
[](auto list, auto prop) {
return std::move(list) + ", " + prop.first;
});
- log<level::ERR>("Configured property not available",
- entry("JSON=%s", property.dump().c_str()),
- entry("AVAILABLE_PROPS=%s", props.c_str()));
+ lg2::error(
+ "Configured property not available. Available properties are {AVAILABLE_PROPS}",
+ "JSON", property.dump(), "AVAILABLE_PROPS", props);
throw std::runtime_error(
"Configured property function not available");
}
@@ -564,9 +561,9 @@
std::vector<std::string> values;
if (!jsonObj.contains("values"))
{
- log<level::ERR>("No 'values' found for \"Supported\" property, "
- "using an empty list",
- entry("JSON=%s", jsonObj.dump().c_str()));
+ lg2::error("No 'values' found for \"Supported\" property, "
+ "using an empty list",
+ "JSON", jsonObj.dump());
}
else
{
@@ -574,9 +571,9 @@
{
if (!value.contains("value"))
{
- log<level::ERR>("No 'value' found for \"Supported\" property "
- "entry, skipping",
- entry("JSON=%s", value.dump().c_str()));
+ lg2::error("No 'value' found for \"Supported\" property "
+ "entry, skipping",
+ "JSON", value.dump());
}
else
{
@@ -597,9 +594,9 @@
// Use default value for "Current" property if no "value" entry given
if (!jsonObj.contains("value"))
{
- log<level::INFO>("No 'value' found for \"Current\" property, "
- "using default",
- entry("JSON=%s", jsonObj.dump().c_str()));
+ lg2::info("No 'value' found for \"Current\" property, "
+ "using default",
+ "JSON", jsonObj.dump());
// Set persist state of property
return Zone::setPropertyPersist(DBusZone::thermalModeIntf,
DBusZone::currentProp, persist);
diff --git a/control/main.cpp b/control/main.cpp
index 9286dc7..fddfb25 100644
--- a/control/main.cpp
+++ b/control/main.cpp
@@ -28,7 +28,7 @@
#include "sdbusplus.hpp"
#include "sdeventplus.hpp"
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus.hpp>
#include <sdeventplus/event.hpp>
#include <sdeventplus/source/signal.hpp>
@@ -37,7 +37,6 @@
#include <fstream>
using namespace phosphor::fan::control;
-using namespace phosphor::logging;
#ifdef CONTROL_USE_JSON
void dumpFlightRecorder()
@@ -129,25 +128,23 @@
// return 1 so it is restarted without a core dump.
catch (const phosphor::fan::util::DBusServiceError& e)
{
- log<level::ERR>("Uncaught DBus service lookup failure exception",
- entry("PATH=%s", e.path.c_str()),
- entry("INTERFACE=%s", e.interface.c_str()));
+ lg2::error(
+ "Uncaught DBus service lookup failure exception, Path={PATH}, Interface={INTERFACE}",
+ "PATH", e.path, "INTERFACE", e.interface);
}
catch (const phosphor::fan::util::DBusMethodError& e)
{
- log<level::ERR>("Uncaught DBus method failure exception",
- entry("BUSNAME=%s", e.busName.c_str()),
- entry("PATH=%s", e.path.c_str()),
- entry("INTERFACE=%s", e.interface.c_str()),
- entry("METHOD=%s", e.method.c_str()));
+ lg2::error(
+ "Uncaught DBus method failure exception, Busname={BUSNAME}, Path={PATH}, Interface={INTERFACE}, Method={METHOD}",
+ "BUSNAME", e.busName, "PATH", e.path, "INTERFACE", e.interface,
+ "METHOD", e.method);
}
catch (const phosphor::fan::util::DBusPropertyError& e)
{
- log<level::ERR>("Uncaught DBus property access failure exception",
- entry("BUSNAME=%s", e.busName.c_str()),
- entry("PATH=%s", e.path.c_str()),
- entry("INTERFACE=%s", e.interface.c_str()),
- entry("PROPERTY=%s", e.property.c_str()));
+ lg2::error(
+ "Uncaught DBus property access failure exception, Busname={BUSNAME}, Path={PATH}, Interface={INTERFACE}, Property={PROPERTY}",
+ "BUSNAME", e.busName, "PATH", e.path, "INTERFACE", e.interface,
+ "PROPERTY", e.property);
}
catch (std::exception& e)
{
diff --git a/control/preconditions.cpp b/control/preconditions.cpp
index 13f51db..9991f78 100644
--- a/control/preconditions.cpp
+++ b/control/preconditions.cpp
@@ -2,7 +2,7 @@
#include "zone.hpp"
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <algorithm>
@@ -16,7 +16,6 @@
{
using namespace phosphor::fan;
-using namespace phosphor::logging;
Action property_states_match(std::vector<PrecondGroup>&& pg,
std::vector<SetSpeedEvent>&& sse)
@@ -42,9 +41,9 @@
if (precondState)
{
- log<level::DEBUG>(
- "Preconditions passed, init the associated events",
- entry("EVENT_COUNT=%u", sse.size()));
+ lg2::debug(
+ "Preconditions passed, init the associated events, Event_Count={EVENT_COUNT}",
+ "EVENT_COUNT", sse.size());
// Init the events when all the precondition(s) are true
std::for_each(sse.begin(), sse.end(), [&zone](const auto& entry) {
zone.initEvent(entry);
@@ -52,9 +51,9 @@
}
else
{
- log<level::DEBUG>(
- "Preconditions not met for events, events removed if present",
- entry("EVENT_COUNT=%u", sse.size()));
+ lg2::debug(
+ "Preconditions not met for events, events removed if present, Event_Count={EVENT_COUNT}",
+ "EVENT_COUNT", sse.size());
// Unsubscribe the events' signals when any precondition is false
std::for_each(sse.begin(), sse.end(), [&zone](const auto& entry) {
zone.removeEvent(entry);
diff --git a/control/zone.cpp b/control/zone.cpp
index 6031d53..3fb8cda 100644
--- a/control/zone.cpp
+++ b/control/zone.cpp
@@ -24,7 +24,7 @@
#include <cereal/cereal.hpp>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
#include <chrono>
@@ -42,7 +42,6 @@
using namespace std::chrono;
using namespace phosphor::fan;
-using namespace phosphor::logging;
namespace fs = std::filesystem;
using InternalFailure =
sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
@@ -590,7 +589,8 @@
}
catch (const std::exception& e)
{
- log<level::ERR>(e.what());
+ lg2::error("Exception restoring current zone mode: {ERROR}", "ERROR",
+ e);
fs::remove(path);
current = ThermalObject::current();
}