use std::format instead of fmt::format
The std::format is sufficient for the uses in this repository except
for in one file (override_fan_target.cpp, since P2286 isn't supported
by GCC yet). Switch to std::format whenever possible.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ib2576fb530a4d7ce238e1b0bd95b40b476ec2107
diff --git a/control/json/actions/action.hpp b/control/json/actions/action.hpp
index dcba6ea..0377a8a 100644
--- a/control/json/actions/action.hpp
+++ b/control/json/actions/action.hpp
@@ -20,12 +20,11 @@
#include "config_base.hpp"
#include "group.hpp"
-#include <fmt/format.h>
-
#include <nlohmann/json.hpp>
#include <phosphor-logging/log.hpp>
#include <algorithm>
+#include <format>
#include <functional>
#include <iterator>
#include <map>
@@ -67,7 +66,7 @@
*/
ActionParseError(const std::string& name, const std::string& details) :
std::runtime_error(
- fmt::format("Failed to parse action {} [{}]", name, details)
+ std::format("Failed to parse action {} [{}]", name, details)
.c_str())
{}
};
@@ -299,7 +298,7 @@
else
{
log<level::ERR>(
- fmt::format("Action '{}' is already registered", name).c_str());
+ std::format("Action '{}' is already registered", name).c_str());
throw std::runtime_error("Actions with the same name found");
}
@@ -338,7 +337,7 @@
return std::move(list) + ", " + act.first;
});
log<level::ERR>(
- fmt::format("Action '{}' is not registered", name).c_str(),
+ std::format("Action '{}' is not registered", name).c_str(),
entry("AVAILABLE_ACTIONS=%s", acts.c_str()));
throw std::runtime_error("Unsupported action name given");
}
diff --git a/control/json/actions/count_state_target.cpp b/control/json/actions/count_state_target.cpp
index dcbd70d..b2a900b 100644
--- a/control/json/actions/count_state_target.cpp
+++ b/control/json/actions/count_state_target.cpp
@@ -20,10 +20,10 @@
#include "action.hpp"
#include "group.hpp"
-#include <fmt/format.h>
-
#include <nlohmann/json.hpp>
+#include <format>
+
namespace phosphor::fan::control::json
{
diff --git a/control/json/actions/mapped_floor.cpp b/control/json/actions/mapped_floor.cpp
index c947098..97f659f 100644
--- a/control/json/actions/mapped_floor.cpp
+++ b/control/json/actions/mapped_floor.cpp
@@ -20,11 +20,10 @@
#include "group.hpp"
#include "sdeventplus.hpp"
-#include <fmt/format.h>
-
#include <nlohmann/json.hpp>
#include <algorithm>
+#include <format>
namespace phosphor::fan::control::json
{
@@ -43,7 +42,7 @@
if (newFloor < 0)
{
log<level::ERR>(
- fmt::format("{}: Floor offset of {} resulted in negative floor",
+ std::format("{}: Floor offset of {} resulted in negative floor",
actionName, offset)
.c_str());
return floor;
@@ -72,7 +71,7 @@
{
throw ActionParseError{
ActionBase::getName(),
- fmt::format("Group name {} is not a valid group", name)};
+ std::format("Group name {} is not a valid group", name)};
}
return &(*groupIt);
@@ -195,7 +194,7 @@
{
throw ActionParseError{
ActionBase::getName(),
- fmt::format("condition_group {} must only have 1 member",
+ std::format("condition_group {} must only have 1 member",
_conditionGroup->getName())};
}
@@ -267,7 +266,7 @@
!std::is_same_v<int32_t, V> &&
!std::is_same_v<int64_t, V>)
{
- throw std::runtime_error{fmt::format(
+ throw std::runtime_error{std::format(
"{}: Group {} has more than one member but "
"isn't numeric",
ActionBase::getName(), group.getName())};
@@ -404,7 +403,7 @@
// If the parameter isn't there, then don't use
// this floor table
log<level::DEBUG>(
- fmt::format("{}: Parameter {} specified in the JSON "
+ std::format("{}: Parameter {} specified in the JSON "
"could not be found",
ActionBase::getName(),
std::get<std::string>(groupOrParameter))
diff --git a/control/json/actions/missing_owner_target.cpp b/control/json/actions/missing_owner_target.cpp
index 30f91b4..2138a06 100644
--- a/control/json/actions/missing_owner_target.cpp
+++ b/control/json/actions/missing_owner_target.cpp
@@ -19,12 +19,11 @@
#include "../zone.hpp"
#include "group.hpp"
-#include <fmt/format.h>
-
#include <nlohmann/json.hpp>
#include <phosphor-logging/log.hpp>
#include <algorithm>
+#include <format>
namespace phosphor::fan::control::json
{
diff --git a/control/json/actions/net_target_decrease.cpp b/control/json/actions/net_target_decrease.cpp
index 044622d..a9fe8d1 100644
--- a/control/json/actions/net_target_decrease.cpp
+++ b/control/json/actions/net_target_decrease.cpp
@@ -20,12 +20,11 @@
#include "action.hpp"
#include "group.hpp"
-#include <fmt/format.h>
-
#include <nlohmann/json.hpp>
#include <phosphor-logging/log.hpp>
#include <algorithm>
+#include <format>
#include <variant>
namespace phosphor::fan::control::json
@@ -124,7 +123,7 @@
{
// Unsupported group member type for this action
log<level::ERR>(
- fmt::format("Action {}: Unsupported group member type "
+ std::format("Action {}: Unsupported group member type "
"given. [object = {} : {} : {}]",
ActionBase::getName(), member,
group.getInterface(), group.getProperty())
diff --git a/control/json/actions/net_target_increase.cpp b/control/json/actions/net_target_increase.cpp
index 878dd3f..7341a35 100644
--- a/control/json/actions/net_target_increase.cpp
+++ b/control/json/actions/net_target_increase.cpp
@@ -20,12 +20,11 @@
#include "action.hpp"
#include "group.hpp"
-#include <fmt/format.h>
-
#include <nlohmann/json.hpp>
#include <phosphor-logging/log.hpp>
#include <algorithm>
+#include <format>
#include <variant>
namespace phosphor::fan::control::json
@@ -117,7 +116,7 @@
{
// Unsupported group member type for this action
log<level::ERR>(
- fmt::format("Action {}: Unsupported group member type "
+ std::format("Action {}: Unsupported group member type "
"given. [object = {} : {} : {}]",
ActionBase::getName(), member,
group.getInterface(), group.getProperty())
diff --git a/control/json/actions/pcie_card_floors.cpp b/control/json/actions/pcie_card_floors.cpp
index 3d242d3..106d42f 100644
--- a/control/json/actions/pcie_card_floors.cpp
+++ b/control/json/actions/pcie_card_floors.cpp
@@ -67,7 +67,7 @@
if (group.getInterface() != powerStateIface)
{
log<level::DEBUG>(
- fmt::format("Wrong interface {} in PCIe card floor group",
+ std::format("Wrong interface {} in PCIe card floor group",
group.getInterface())
.c_str());
continue;
@@ -85,7 +85,7 @@
catch (const std::out_of_range& oore)
{
log<level::ERR>(
- fmt::format("Could not get power state for {}", slotPath)
+ std::format("Could not get power state for {}", slotPath)
.c_str());
continue;
}
@@ -117,7 +117,7 @@
}
}
- auto status = fmt::format(
+ auto status = std::format(
"Found {} hot cards, {} with temp sensors, {} uninteresting", hotCards,
numTempSensorCards, uninterestingCards);
if (status != _lastStatus)
@@ -137,14 +137,14 @@
{
if (origIndex != floorIndex)
{
- record(fmt::format("Setting {} parameter to {}", floorIndexParam,
+ record(std::format("Setting {} parameter to {}", floorIndexParam,
floorIndex));
Manager::setParameter(floorIndexParam, floorIndex);
}
}
else if (origIndexVariant)
{
- record(fmt::format("Removing parameter {}", floorIndexParam));
+ record(std::format("Removing parameter {}", floorIndexParam));
Manager::setParameter(floorIndexParam, std::nullopt);
}
}
@@ -188,7 +188,7 @@
catch (const std::out_of_range& oore)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"{}: Could not get PCIeDevice property {} {} from cache ",
ActionBase::getName(), objectPath, propertyName)
.c_str());
@@ -203,7 +203,7 @@
catch (const std::invalid_argument& e)
{
log<level::INFO>(
- fmt::format("{}: {} has invalid PCIeDevice property {} value: {}",
+ std::format("{}: {} has invalid PCIeDevice property {} value: {}",
ActionBase::getName(), objectPath, propertyName,
std::get<std::string>(variantValue))
.c_str());
@@ -258,7 +258,7 @@
if (it == _pcieDevices.end())
{
- throw std::runtime_error(fmt::format(
+ throw std::runtime_error(std::format(
"Could not find PCIe card object path for slot {}", slotPath));
}
diff --git a/control/json/actions/request_target_base.cpp b/control/json/actions/request_target_base.cpp
index 4bcaabb..f52a19b 100644
--- a/control/json/actions/request_target_base.cpp
+++ b/control/json/actions/request_target_base.cpp
@@ -19,12 +19,11 @@
#include "../zone.hpp"
#include "group.hpp"
-#include <fmt/format.h>
-
#include <nlohmann/json.hpp>
#include <phosphor-logging/log.hpp>
#include <algorithm>
+#include <format>
namespace phosphor::fan::control::json
{
@@ -75,7 +74,7 @@
{
// Unsupported group member type for this action
log<level::ERR>(
- fmt::format("Action {}: Unsupported group member type "
+ std::format("Action {}: Unsupported group member type "
"given. [object = {} : {} : {}]",
getName(), member, group.getInterface(),
group.getProperty())
diff --git a/control/json/actions/set_parameter_from_group_max.cpp b/control/json/actions/set_parameter_from_group_max.cpp
index b42f582..10c2b70 100644
--- a/control/json/actions/set_parameter_from_group_max.cpp
+++ b/control/json/actions/set_parameter_from_group_max.cpp
@@ -17,7 +17,7 @@
#include "../manager.hpp"
-#include <fmt/format.h>
+#include <format>
namespace phosphor::fan::control::json
{
@@ -69,7 +69,7 @@
!std::is_same_v<int32_t, V> &&
!std::is_same_v<int64_t, V>)
{
- log<level::ERR>(fmt::format("{}: Group {} has more "
+ log<level::ERR>(std::format("{}: Group {} has more "
"than one member but "
"isn't numeric",
ActionBase::getName(),
@@ -105,7 +105,7 @@
catch (const std::exception& e)
{
log<level::ERR>(
- fmt::format("{}: Could not perform modifier operation: {}",
+ std::format("{}: Could not perform modifier operation: {}",
ActionBase::getName(), e.what())
.c_str());
return;
diff --git a/control/json/actions/target_from_group_max.cpp b/control/json/actions/target_from_group_max.cpp
index 79cacf8..045b2d5 100644
--- a/control/json/actions/target_from_group_max.cpp
+++ b/control/json/actions/target_from_group_max.cpp
@@ -17,8 +17,7 @@
#include "../manager.hpp"
-#include <fmt/format.h>
-
+#include <format>
#include <iostream>
namespace phosphor::fan::control::json
@@ -191,7 +190,7 @@
!std::is_same_v<int32_t, V> &&
!std::is_same_v<int64_t, V>)
{
- log<level::ERR>(fmt::format("{}: Group {}'s member "
+ log<level::ERR>(std::format("{}: Group {}'s member "
"isn't numeric",
ActionBase::getName(),
group.getName())
diff --git a/control/json/actions/timer_based_actions.cpp b/control/json/actions/timer_based_actions.cpp
index e3f3fec..81d8fc1 100644
--- a/control/json/actions/timer_based_actions.cpp
+++ b/control/json/actions/timer_based_actions.cpp
@@ -23,12 +23,11 @@
#include "sdeventplus.hpp"
#include "zone.hpp"
-#include <fmt/format.h>
-
#include <nlohmann/json.hpp>
#include <algorithm>
#include <chrono>
+#include <format>
namespace phosphor::fan::control::json
{
@@ -180,7 +179,7 @@
else
{
throw ActionParseError{
- getName(), fmt::format("Timer type '{}' is not supported", type)};
+ getName(), std::format("Timer type '{}' is not supported", type)};
}
}
diff --git a/control/json/dbus_zone.cpp b/control/json/dbus_zone.cpp
index 6397151..6e269c3 100644
--- a/control/json/dbus_zone.cpp
+++ b/control/json/dbus_zone.cpp
@@ -21,14 +21,13 @@
#include "sdbusplus.hpp"
#include "zone.hpp"
-#include <fmt/format.h>
-
#include <cereal/archives/json.hpp>
#include <cereal/cereal.hpp>
#include <phosphor-logging/log.hpp>
#include <algorithm>
#include <filesystem>
+#include <format>
#include <fstream>
namespace phosphor::fan::control::json
@@ -92,7 +91,7 @@
std::error_code ec;
fs::remove(path, ec);
log<level::ERR>(
- fmt::format("Unable to restore persisted `Current` thermal mode "
+ std::format("Unable to restore persisted `Current` thermal mode "
"property ({}, ec: {})",
e.what(), ec.value())
.c_str());
diff --git a/control/json/event.cpp b/control/json/event.cpp
index 74f2ddf..3a74f30 100644
--- a/control/json/event.cpp
+++ b/control/json/event.cpp
@@ -22,13 +22,12 @@
#include "sdbusplus.hpp"
#include "trigger.hpp"
-#include <fmt/format.h>
-
#include <nlohmann/json.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
#include <algorithm>
+#include <format>
#include <optional>
namespace phosphor::fan::control::json
@@ -148,7 +147,7 @@
{
if (!jsonGrp.contains("name"))
{
- auto msg = fmt::format("Missing required group name attribute");
+ 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());
@@ -222,7 +221,7 @@
if (actionZones.empty())
{
log<level::DEBUG>(
- fmt::format("No zones configured for event {}'s action {} "
+ std::format("No zones configured for event {}'s action {} "
"based on the active profile(s)",
getName(), jsonAct["name"].get<std::string>())
.c_str());
@@ -260,7 +259,7 @@
if (actionGroups.empty() && _groups.empty())
{
log<level::DEBUG>(
- fmt::format("No groups configured for event {}'s action {} "
+ std::format("No groups configured for event {}'s action {} "
"based on the active profile(s)",
getName(), jsonAct["name"].get<std::string>())
.c_str());
@@ -303,7 +302,7 @@
return std::move(list) + ", " + trig.first;
});
log<level::ERR>(
- fmt::format("Trigger '{}' is not recognized", tClass).c_str(),
+ std::format("Trigger '{}' is not recognized", tClass).c_str(),
entry("AVAILABLE_TRIGGERS=%s", availTrigs.c_str()));
throw std::runtime_error("Unsupported trigger class name given");
}
diff --git a/control/json/fan.cpp b/control/json/fan.cpp
index 26b2174..0010d2b 100644
--- a/control/json/fan.cpp
+++ b/control/json/fan.cpp
@@ -17,12 +17,12 @@
#include "sdbusplus.hpp"
-#include <fmt/format.h>
-
#include <nlohmann/json.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
+#include <format>
+
namespace phosphor::fan::control::json
{
@@ -117,7 +117,7 @@
catch (const sdbusplus::exception_t&)
{
throw util::DBusPropertyError{
- fmt::format("Failed to set target for fan {}", _name).c_str(),
+ std::format("Failed to set target for fan {}", _name).c_str(),
sensor.second, sensor.first, _interface, FAN_TARGET_PROPERTY};
}
}
diff --git a/control/json/manager.cpp b/control/json/manager.cpp
index fe5fc0d..5121e97 100644
--- a/control/json/manager.cpp
+++ b/control/json/manager.cpp
@@ -97,7 +97,7 @@
log<level::ERR>("Error reloading configs, no changes made",
entry("LOAD_ERROR=%s", re.what()));
FlightRecorder::instance().log(
- "main", fmt::format("Error reloading configs, no changes made: {}",
+ "main", std::format("Error reloading configs, no changes made: {}",
re.what()));
}
}
@@ -539,7 +539,7 @@
{
// Log service not found for object
log<level::DEBUG>(
- fmt::format(
+ std::format(
"Unable to get service name for path {}, interface {}",
path, intf)
.c_str());
diff --git a/control/json/manager.hpp b/control/json/manager.hpp
index ad92720..369b6bf 100644
--- a/control/json/manager.hpp
+++ b/control/json/manager.hpp
@@ -25,8 +25,6 @@
#include "utils/flight_recorder.hpp"
#include "zone.hpp"
-#include <fmt/format.h>
-
#include <nlohmann/json.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
@@ -36,6 +34,7 @@
#include <sdeventplus/utility/timer.hpp>
#include <chrono>
+#include <format>
#include <map>
#include <memory>
#include <optional>
@@ -210,7 +209,7 @@
if (!confFile.empty())
{
FlightRecorder::instance().log(
- "main", fmt::format("Loading configuration from {}",
+ "main", std::format("Loading configuration from {}",
confFile.string()));
for (const auto& entry : fan::JsonConfig::load(confFile))
{
@@ -242,11 +241,11 @@
std::move(obj));
}
log<level::INFO>(
- fmt::format("Configuration({}) loaded successfully",
+ std::format("Configuration({}) loaded successfully",
T::confFileName)
.c_str());
FlightRecorder::instance().log(
- "main", fmt::format("Configuration({}) loaded successfully",
+ "main", std::format("Configuration({}) loaded successfully",
T::confFileName));
}
return config;
diff --git a/control/json/triggers/init.cpp b/control/json/triggers/init.cpp
index f51a09e..32277d7 100644
--- a/control/json/triggers/init.cpp
+++ b/control/json/triggers/init.cpp
@@ -21,12 +21,11 @@
#include "sdbusplus.hpp"
#include "trigger_aliases.hpp"
-#include <fmt/format.h>
-
#include <nlohmann/json.hpp>
#include <phosphor-logging/log.hpp>
#include <algorithm>
+#include <format>
#include <iterator>
#include <memory>
#include <numeric>
@@ -109,7 +108,7 @@
// TODO How to handle this? Create timer to keep checking for
// object/service to appear? When to stop checking?
log<level::ERR>(
- fmt::format(
+ std::format(
"Unable to get service name for path {}, interface {}",
member, intf)
.c_str());
@@ -128,7 +127,7 @@
// 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>(fmt::format("Unable to get service({}) owner "
+ log<level::ERR>(std::format("Unable to get service({}) owner "
"state for path {}, interface {}",
servName, member, intf)
.c_str());
@@ -167,7 +166,7 @@
return std::move(list) + ", " + method.first;
});
auto msg =
- fmt::format("Event '{}' requires a supported method given to "
+ std::format("Event '{}' requires a supported method given to "
"be init driven, available methods: {}",
eventName, availMethods);
log<level::ERR>(msg.c_str());
diff --git a/control/json/triggers/parameter.cpp b/control/json/triggers/parameter.cpp
index 6f4eac3..6986608 100644
--- a/control/json/triggers/parameter.cpp
+++ b/control/json/triggers/parameter.cpp
@@ -17,7 +17,7 @@
#include "../manager.hpp"
-#include <fmt/format.h>
+#include <format>
namespace phosphor::fan::control::json::trigger::parameter
{
@@ -30,7 +30,7 @@
{
if (!jsonObj.contains("parameter"))
{
- auto msg = fmt::format(
+ auto msg = std::format(
"Event '{}' parameter trigger is missing 'parameter'", eventName);
log<level::ERR>(msg.c_str());
throw std::runtime_error(msg);
diff --git a/control/json/triggers/signal.cpp b/control/json/triggers/signal.cpp
index 7169d69..5e78d6e 100644
--- a/control/json/triggers/signal.cpp
+++ b/control/json/triggers/signal.cpp
@@ -21,13 +21,12 @@
#include "handlers.hpp"
#include "trigger_aliases.hpp"
-#include <fmt/format.h>
-
#include <nlohmann/json.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus/match.hpp>
#include <algorithm>
+#include <format>
#include <functional>
#include <iterator>
#include <memory>
@@ -206,7 +205,7 @@
// TODO How to handle this? Create timer to keep checking for
// service to appear? When to stop checking?
log<level::ERR>(
- fmt::format("Events will not be triggered by name owner changed"
+ std::format("Events will not be triggered by name owner changed"
"signals from service of path {}, interface {}",
member, group.getInterface())
.c_str());
@@ -256,7 +255,7 @@
return std::move(list) + ", " + signal.first;
});
auto msg =
- fmt::format("Event '{}' requires a supported signal given to be "
+ std::format("Event '{}' requires a supported signal given to be "
"triggered by signal, available signals: {}",
eventName, availSignals);
log<level::ERR>(msg.c_str());
diff --git a/control/json/triggers/timer.cpp b/control/json/triggers/timer.cpp
index ce8bba7..2036042 100644
--- a/control/json/triggers/timer.cpp
+++ b/control/json/triggers/timer.cpp
@@ -19,12 +19,11 @@
#include "group.hpp"
#include "trigger_aliases.hpp"
-#include <fmt/format.h>
-
#include <nlohmann/json.hpp>
#include <phosphor-logging/log.hpp>
#include <chrono>
+#include <format>
namespace phosphor::fan::control::json::trigger::timer
{
@@ -52,7 +51,7 @@
else
{
log<level::ERR>(
- fmt::format("Timer trigger type '{}' is not supported", type)
+ std::format("Timer trigger type '{}' is not supported", type)
.c_str(),
entry("AVAILABLE_TYPES={oneshot, repeating}"));
throw std::runtime_error("Unsupported timer trigger type given");
diff --git a/control/json/utils/flight_recorder.cpp b/control/json/utils/flight_recorder.cpp
index 8c8ce06..00325f5 100644
--- a/control/json/utils/flight_recorder.cpp
+++ b/control/json/utils/flight_recorder.cpp
@@ -15,12 +15,11 @@
*/
#include "flight_recorder.hpp"
-#include <fmt/format.h>
-
#include <phosphor-logging/log.hpp>
#include <algorithm>
#include <ctime>
+#include <format>
#include <iomanip>
#include <sstream>
#include <vector>
diff --git a/control/json/utils/modifier.cpp b/control/json/utils/modifier.cpp
index 91978e7..c8fb536 100644
--- a/control/json/utils/modifier.cpp
+++ b/control/json/utils/modifier.cpp
@@ -19,10 +19,10 @@
#include "json/config_base.hpp"
#include "json/manager.hpp"
-#include <fmt/format.h>
-
#include <phosphor-logging/log.hpp>
+#include <format>
+
using namespace phosphor::logging;
namespace phosphor::fan::control::json
@@ -168,7 +168,7 @@
if (!valueArray.is_array())
{
log<level::ERR>(
- fmt::format("Invalid JSON data for less_than config: {}",
+ std::format("Invalid JSON data for less_than config: {}",
valueArray.dump())
.c_str());
throw std::invalid_argument("Invalid modifier JSON");
@@ -180,7 +180,7 @@
!valueEntry.contains("parameter_value"))
{
log<level::ERR>(
- fmt::format("Missing arg_value or parameter_value keys "
+ std::format("Missing arg_value or parameter_value keys "
"in less_than config: {}",
valueArray.dump())
.c_str());
@@ -192,7 +192,7 @@
if (std::holds_alternative<bool>(argVal))
{
log<level::ERR>(
- fmt::format(
+ std::format(
"Invalid data type in arg_value key in modifier JSON "
"config: {}",
valueArray.dump())
@@ -208,7 +208,7 @@
if (rangeValues.empty())
{
- log<level::ERR>(fmt::format("No valid range values found in "
+ log<level::ERR>(std::format("No valid range values found in "
"modifier json: {}",
valueArray.dump())
.c_str());
@@ -292,7 +292,7 @@
if (!jsonObj.contains("operator") || !jsonObj.contains("value"))
{
log<level::ERR>(
- fmt::format(
+ std::format(
"Modifier entry in JSON missing 'operator' or 'value': {}",
jsonObj.dump())
.c_str());
@@ -311,7 +311,7 @@
}
else
{
- log<level::ERR>(fmt::format("Invalid operator in the modifier JSON: {}",
+ log<level::ERR>(std::format("Invalid operator in the modifier JSON: {}",
jsonObj.dump())
.c_str());
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 6fd8fd1..8032081 100644
--- a/control/json/utils/pcie_card_metadata.cpp
+++ b/control/json/utils/pcie_card_metadata.cpp
@@ -19,8 +19,7 @@
#include "json_config.hpp"
#include "utils/flight_recorder.hpp"
-#include <fmt/format.h>
-
+#include <format>
#include <iostream>
static constexpr auto cardFileName = "pcie_cards.json";
@@ -52,12 +51,12 @@
{
FlightRecorder::instance().log(
"main",
- fmt::format("Loading configuration from {}", confFile.string()));
+ std::format("Loading configuration from {}", confFile.string()));
load(JsonConfig::load(confFile));
FlightRecorder::instance().log(
- "main", fmt::format("Configuration({}) loaded successfully",
+ "main", std::format("Configuration({}) loaded successfully",
confFile.string()));
- log<level::INFO>(fmt::format("Configuration({}) loaded successfully",
+ log<level::INFO>(std::format("Configuration({}) loaded successfully",
confFile.string())
.c_str());
}
@@ -80,14 +79,14 @@
if (fs::exists(confFile))
{
FlightRecorder::instance().log(
- "main", fmt::format("Loading configuration from {}",
+ "main", std::format("Loading configuration from {}",
confFile.string()));
load(JsonConfig::load(confFile));
FlightRecorder::instance().log(
- "main", fmt::format("Configuration({}) loaded successfully",
+ "main", std::format("Configuration({}) loaded successfully",
confFile.string()));
log<level::INFO>(
- fmt::format("Configuration({}) loaded successfully",
+ std::format("Configuration({}) loaded successfully",
confFile.string())
.c_str());
}
@@ -105,7 +104,7 @@
if (!json.contains("cards") || !json.at("cards").is_array())
{
throw std::runtime_error{
- fmt::format("Missing 'cards' array in PCIe card JSON")};
+ std::format("Missing 'cards' array in PCIe card JSON")};
}
for (const auto& card : json.at("cards"))
@@ -169,7 +168,7 @@
uint16_t subsystemID,
uint16_t subsystemVendorID) const
{
- log<level::DEBUG>(fmt::format("Lookup {:#x} ${:#x} {:#x} {:#x}", deviceID,
+ log<level::DEBUG>(std::format("Lookup {:#x} ${:#x} {:#x} {:#x}", deviceID,
vendorID, subsystemID, subsystemVendorID)
.c_str());
auto card = std::find_if(_cards.begin(), _cards.end(),
diff --git a/control/json/zone.cpp b/control/json/zone.cpp
index 2e31465..487a7d4 100644
--- a/control/json/zone.cpp
+++ b/control/json/zone.cpp
@@ -81,7 +81,7 @@
if (_defaultFloor > _ceiling)
{
log<level::ERR>(
- fmt::format("Configured default_floor({}) above ceiling({}), "
+ std::format("Configured default_floor({}) above ceiling({}), "
"setting default floor to ceiling",
_defaultFloor, _ceiling)
.c_str());
@@ -149,7 +149,7 @@
{
FlightRecorder::instance().log(
"zone-set-target" + getName(),
- fmt::format("Set target {} (from {})", target, _target));
+ std::format("Set target {} (from {})", target, _target));
}
_target = target;
for (auto& fan : _fans)
@@ -173,7 +173,7 @@
else
{
log<level::DEBUG>(
- fmt::format("Configured fan {} not found in zone {} to lock target",
+ std::format("Configured fan {} not found in zone {} to lock target",
fname, getName())
.c_str());
}
@@ -196,7 +196,7 @@
else
{
log<level::DEBUG>(
- fmt::format(
+ std::format(
"Configured fan {} not found in zone {} to unlock target",
fname, getName())
.c_str());
@@ -214,7 +214,7 @@
{
FlightRecorder::instance().log(
"zone-target"s + getName(),
- fmt::format("{} is removing target hold", ident));
+ std::format("{} is removing target hold", ident));
}
}
else
@@ -224,7 +224,7 @@
{
FlightRecorder::instance().log(
"zone-target"s + getName(),
- fmt::format("{} is setting target hold to {}", ident, target));
+ std::format("{} is setting target hold to {}", ident, target));
}
_targetHolds[ident] = target;
_isActive = false;
@@ -244,7 +244,7 @@
{
FlightRecorder::instance().log(
"zone-target"s + getName(),
- fmt::format("Settings fans to target hold of {}",
+ std::format("Settings fans to target hold of {}",
itHoldMax->second));
}
@@ -272,7 +272,7 @@
{
FlightRecorder::instance().log(
"zone-floor"s + getName(),
- fmt::format("{} is removing floor hold", ident));
+ std::format("{} is removing floor hold", ident));
}
}
else
@@ -282,7 +282,7 @@
{
FlightRecorder::instance().log(
"zone-floor"s + getName(),
- fmt::format("{} is setting floor hold to {}", ident, target));
+ std::format("{} is setting floor hold to {}", ident, target));
}
_floorHolds[ident] = target;
}
@@ -303,7 +303,7 @@
{
FlightRecorder::instance().log(
"zone-floor"s + getName(),
- fmt::format("No set floor exists, using default floor",
+ std::format("No set floor exists, using default floor",
_defaultFloor));
}
_floor = _defaultFloor;
@@ -314,7 +314,7 @@
{
FlightRecorder::instance().log(
"zone-floor"s + getName(),
- fmt::format("Setting new floor to {}", itHoldMax->second));
+ std::format("Setting new floor to {}", itHoldMax->second));
}
_floor = itHoldMax->second;
}
diff --git a/cooling-type/cooling_type.cpp b/cooling-type/cooling_type.cpp
index c82dbe0..2df84bd 100644
--- a/cooling-type/cooling_type.cpp
+++ b/cooling-type/cooling_type.cpp
@@ -4,7 +4,6 @@
#include "utility.hpp"
#include <fcntl.h>
-#include <fmt/format.h>
#include <libevdev/libevdev.h>
#include <unistd.h>
@@ -14,6 +13,8 @@
#include <sdbusplus/bus.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <format>
+
namespace phosphor
{
namespace cooling
@@ -37,7 +38,7 @@
}
log<level::ERR>(
- fmt::format(
+ std::format(
"Failed to get libevdev from file descriptor {}, return code {}",
fd, rc)
.c_str());
@@ -69,7 +70,7 @@
if (0 == fetch_rc)
{
log<level::ERR>(
- fmt::format("Device does not support event type keycode {}",
+ std::format("Device does not support event type keycode {}",
keycode)
.c_str());
elog<InternalFailure>();
diff --git a/cooling-type/main.cpp b/cooling-type/main.cpp
index c4dc57f..2c31757 100644
--- a/cooling-type/main.cpp
+++ b/cooling-type/main.cpp
@@ -1,12 +1,11 @@
#include "cooling_type.hpp"
#include "sdbusplus.hpp"
-#include <fmt/format.h>
-
#include <CLI/CLI.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
+#include <format>
#include <iostream>
#include <memory>
@@ -83,7 +82,7 @@
}
catch (const DBusMethodError& dme)
{
- log<level::ERR>(fmt::format("Uncaught DBus method failure exception "
+ log<level::ERR>(std::format("Uncaught DBus method failure exception "
"Busname: {} "
"Path: {} "
"Interface: {} "
diff --git a/hwmon_ffdc.cpp b/hwmon_ffdc.cpp
index d8069e4..cd8417a 100644
--- a/hwmon_ffdc.cpp
+++ b/hwmon_ffdc.cpp
@@ -2,10 +2,9 @@
#include "logging.hpp"
-#include <fmt/format.h>
-
#include <array>
#include <filesystem>
+#include <format>
#include <fstream>
#include <string>
#include <vector>
@@ -28,7 +27,7 @@
if (!pipe)
{
getLogger().log(
- fmt::format("popen() failed when running command: {}", command));
+ std::format("popen() failed when running command: {}", command));
return output;
}
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr)
@@ -46,7 +45,7 @@
if (!fs::exists(hwmonBaseDir))
{
- getLogger().log(fmt::format("Hwmon base directory {} doesn't exist",
+ getLogger().log(std::format("Hwmon base directory {} doesn't exist",
hwmonBaseDir.native()));
return hwmonNames;
}
@@ -76,7 +75,7 @@
catch (const std::exception& e)
{
getLogger().log(
- fmt::format("Error traversing hwmon directories: {}", e.what()));
+ std::format("Error traversing hwmon directories: {}", e.what()));
}
return hwmonNames;
diff --git a/json_config.hpp b/json_config.hpp
index b12cdb9..c3f041f 100644
--- a/json_config.hpp
+++ b/json_config.hpp
@@ -17,14 +17,13 @@
#include "sdbusplus.hpp"
-#include <fmt/format.h>
-
#include <nlohmann/json.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
#include <sdeventplus/source/signal.hpp>
#include <filesystem>
+#include <format>
#include <fstream>
namespace phosphor::fan
@@ -69,7 +68,7 @@
* @param[in] details - Additional details
*/
NoConfigFound(const std::string& appName, const std::string& fileName) :
- std::runtime_error(fmt::format("JSON configuration not found [Could "
+ std::runtime_error(std::format("JSON configuration not found [Could "
"not find fan {} conf file {}]",
appName, fileName)
.c_str())
@@ -271,7 +270,7 @@
if (!confFile.empty() && fs::exists(confFile))
{
log<level::INFO>(
- fmt::format("Loading configuration from {}", confFile.string())
+ std::format("Loading configuration from {}", confFile.string())
.c_str());
file.open(confFile);
try
@@ -282,12 +281,12 @@
catch (const std::exception& e)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"Failed to parse JSON config file: {}, error: {}",
confFile.string(), e.what())
.c_str());
throw std::runtime_error(
- fmt::format(
+ std::format(
"Failed to parse JSON config file: {}, error: {}",
confFile.string(), e.what())
.c_str());
@@ -295,11 +294,11 @@
}
else
{
- log<level::ERR>(fmt::format("Unable to open JSON config file: {}",
+ log<level::ERR>(std::format("Unable to open JSON config file: {}",
confFile.string())
.c_str());
throw std::runtime_error(
- fmt::format("Unable to open JSON config file: {}",
+ std::format("Unable to open JSON config file: {}",
confFile.string())
.c_str());
}
diff --git a/logger.hpp b/logger.hpp
index 87590e8..77ad13a 100644
--- a/logger.hpp
+++ b/logger.hpp
@@ -2,7 +2,6 @@
#include "utility.hpp"
-#include <fmt/format.h>
#include <unistd.h>
#include <nlohmann/json.hpp>
@@ -11,6 +10,7 @@
#include <cassert>
#include <ctime>
#include <filesystem>
+#include <format>
#include <fstream>
#include <iomanip>
#include <sstream>
@@ -137,12 +137,12 @@
for (const auto& [time, message] : _entries)
{
- auto line = fmt::format("{}: {}\n", time, message);
+ auto line = std::format("{}: {}\n", time, message);
auto rc = write(fd(), line.data(), line.size());
if (rc == -1)
{
auto e = errno;
- auto msg = fmt::format(
+ auto msg = std::format(
"Could not write to temp file {} errno {}", tmpFile, e);
log(msg, Logger::error);
throw std::runtime_error{msg};
diff --git a/monitor/fan.cpp b/monitor/fan.cpp
index 2c29cb3..fc408de 100644
--- a/monitor/fan.cpp
+++ b/monitor/fan.cpp
@@ -21,10 +21,10 @@
#include "types.hpp"
#include "utility.hpp"
-#include <fmt/format.h>
-
#include <phosphor-logging/log.hpp>
+#include <format>
+
namespace phosphor
{
namespace fan
@@ -122,7 +122,7 @@
if (!_present)
{
getLogger().log(
- fmt::format("On startup, fan {} is missing", _name));
+ std::format("On startup, fan {} is missing", _name));
if (_system.isPowerOn() && _fanMissingErrorTimer)
{
_fanMissingErrorTimer->restartOnce(
@@ -161,7 +161,7 @@
if (!_present)
{
- getLogger().log(fmt::format(
+ getLogger().log(std::format(
"New fan {} interface added and fan is not present", _name));
if (_system.isPowerOn() && _fanMissingErrorTimer)
{
@@ -195,7 +195,7 @@
// The tach property still isn't on D-Bus. Ensure
// sensor is nonfunctional, but skip creating an
// error for it since it isn't a fan problem.
- getLogger().log(fmt::format(
+ getLogger().log(std::format(
"Monitoring starting but {} sensor value not on D-Bus",
sensor->name()));
@@ -384,7 +384,7 @@
// isn't on D-Bus as this isn't a fan hardware problem.
sensor.setFunctional(!sensor.functional(), !sensor.hasOwner());
- getLogger().log(fmt::format(
+ getLogger().log(std::format(
"Setting tach sensor {} functional state to {}. "
"[target = {}, actual = {}, allowed range = ({} - {}) "
"owned = {}]",
@@ -402,7 +402,7 @@
if (!_setFuncOnPresent && !_functional &&
!(numNonFuncSensors >= _numSensorFailsForNonFunc))
{
- getLogger().log(fmt::format("Setting fan {} to functional, number "
+ getLogger().log(std::format("Setting fan {} to functional, number "
"of nonfunctional sensors = {}",
_name, numNonFuncSensors));
updateInventory(true);
@@ -413,7 +413,7 @@
// the fan to nonfunctional.
if (_functional && (numNonFuncSensors >= _numSensorFailsForNonFunc))
{
- getLogger().log(fmt::format("Setting fan {} to nonfunctional, "
+ getLogger().log(std::format("Setting fan {} to nonfunctional, "
"number of nonfunctional sensors = {}",
_name, numNonFuncSensors));
updateInventory(false);
@@ -451,7 +451,7 @@
dbusError = true;
getLogger().log(
- fmt::format("D-Bus Exception reading/updating inventory : {}",
+ std::format("D-Bus Exception reading/updating inventory : {}",
e.what()),
Logger::error);
}
@@ -475,7 +475,7 @@
_present = std::get<bool>(presentProp->second);
getLogger().log(
- fmt::format("Fan {} presence state change to {}", _name, _present));
+ std::format("Fan {} presence state change to {}", _name, _present));
if (_present && _setFuncOnPresent)
{
@@ -550,7 +550,7 @@
// Properties still aren't on D-Bus. Let startMonitor()
// deal with it, or maybe System::powerStateChanged() if
// there aren't any sensors at all on D-Bus.
- getLogger().log(fmt::format(
+ getLogger().log(std::format(
"At power on, tach sensor {} value not on D-Bus",
sensor->name()));
}
@@ -572,7 +572,7 @@
else
{
getLogger().log(
- fmt::format("At power on, fan {} is missing", _name));
+ std::format("At power on, fan {} is missing", _name));
if (_fanMissingErrorTimer)
{
diff --git a/monitor/fan_error.cpp b/monitor/fan_error.cpp
index f0a6f32..396b731 100644
--- a/monitor/fan_error.cpp
+++ b/monitor/fan_error.cpp
@@ -73,7 +73,7 @@
if (_fd() == -1)
{
auto e = errno;
- getLogger().log(fmt::format("Could not open FFDC file {}. errno {}",
+ getLogger().log(std::format("Could not open FFDC file {}. errno {}",
_name.string(), e));
}
}
@@ -120,7 +120,7 @@
catch (const DBusError& e)
{
getLogger().log(
- fmt::format("Call to create a {} error for fan {} failed: {}",
+ std::format("Call to create a {} error for fan {} failed: {}",
_errorName, _fanName, e.what()),
Logger::error);
}
@@ -164,7 +164,7 @@
catch (const std::exception& e)
{
log<level::ERR>(
- fmt::format("Could not save log contents in FFDC. Error msg: {}",
+ std::format("Could not save log contents in FFDC. Error msg: {}",
e.what())
.c_str());
}
@@ -194,7 +194,7 @@
else
{
auto e = errno;
- getLogger().log(fmt::format("Failed called to mkstemp, errno = {}", e),
+ getLogger().log(std::format("Failed called to mkstemp, errno = {}", e),
Logger::error);
}
return nullptr;
diff --git a/monitor/json_parser.cpp b/monitor/json_parser.cpp
index 4d06540..b5b7291 100644
--- a/monitor/json_parser.cpp
+++ b/monitor/json_parser.cpp
@@ -23,12 +23,11 @@
#include "tach_sensor.hpp"
#include "types.hpp"
-#include <fmt/format.h>
-
#include <nlohmann/json.hpp>
#include <phosphor-logging/log.hpp>
#include <algorithm>
+#include <format>
#include <map>
#include <memory>
#include <optional>
@@ -213,7 +212,7 @@
auto deviation = fan["deviation"].get<size_t>();
if (100 < deviation)
{
- auto msg = fmt::format(
+ auto msg = std::format(
"Invalid deviation of {} found, must be between 0 and 100",
deviation);
@@ -230,7 +229,7 @@
if (100 < upperDeviation)
{
auto msg =
- fmt::format("Invalid upper_deviation of {} found, must "
+ std::format("Invalid upper_deviation of {} found, must "
"be between 0 and 100",
upperDeviation);
@@ -409,7 +408,7 @@
}
else if (state != "runtime")
{
- auto msg = fmt::format("Invalid power off state entry {}", state);
+ auto msg = std::format("Invalid power off state entry {}", state);
log<level::ERR>(msg.c_str());
throw std::runtime_error(msg.c_str());
}
@@ -449,7 +448,7 @@
else
{
auto msg =
- fmt::format("Invalid power off cause {} in power off config JSON",
+ std::format("Invalid power off cause {} in power off config JSON",
powerOffCause);
log<level::ERR>(msg.c_str());
throw std::runtime_error(msg.c_str());
@@ -509,7 +508,7 @@
}
else
{
- auto msg = fmt::format("Invalid 'type' entry {} in power off config",
+ auto msg = std::format("Invalid 'type' entry {} in power off config",
type);
log<level::ERR>(msg.c_str());
throw std::runtime_error(msg.c_str());
diff --git a/monitor/power_interface.cpp b/monitor/power_interface.cpp
index f6589b8..dbfcfda 100644
--- a/monitor/power_interface.cpp
+++ b/monitor/power_interface.cpp
@@ -49,7 +49,7 @@
catch (const std::exception& e)
{
getLogger().log(
- fmt::format("Caught exception while creating BMC dump: {}",
+ std::format("Caught exception while creating BMC dump: {}",
e.what()),
Logger::error);
}
diff --git a/monitor/power_off_action.hpp b/monitor/power_off_action.hpp
index c833038..6d7580b 100644
--- a/monitor/power_off_action.hpp
+++ b/monitor/power_off_action.hpp
@@ -4,13 +4,12 @@
#include "power_interface.hpp"
#include "sdbusplus.hpp"
-#include <fmt/format.h>
-
#include <sdeventplus/clock.hpp>
#include <sdeventplus/event.hpp>
#include <sdeventplus/utility/timer.hpp>
#include <chrono>
+#include <format>
namespace phosphor::fan::monitor
{
@@ -113,7 +112,7 @@
catch (const std::exception& e)
{
getLogger().log(
- fmt::format("Caught exception while creating BMC dump: {}",
+ std::format("Caught exception while creating BMC dump: {}",
e.what()),
Logger::error);
}
@@ -215,7 +214,7 @@
}
getLogger().log(
- fmt::format("Action '{}' executing hard power off", name()));
+ std::format("Action '{}' executing hard power off", name()));
_powerIface->hardPowerOff();
createBmcDump();
@@ -307,7 +306,7 @@
}
getLogger().log(
- fmt::format("Action '{}' executing soft power off", name()));
+ std::format("Action '{}' executing soft power off", name()));
_powerIface->softPowerOff();
createBmcDump();
@@ -380,7 +379,7 @@
void start() override
{
getLogger().log(
- fmt::format("Action {}: Starting service mode timer", name()));
+ std::format("Action {}: Starting service mode timer", name()));
_serviceModeTimer.restartOnce(_serviceModeDelay);
}
@@ -393,7 +392,7 @@
*/
void serviceModeTimerExpired()
{
- getLogger().log(fmt::format(
+ getLogger().log(std::format(
"Action {}: Service mode timer expired, starting meltdown timer",
name()));
@@ -408,7 +407,7 @@
*/
void meltdownTimerExpired()
{
- getLogger().log(fmt::format(
+ getLogger().log(std::format(
"Action {}: Meltdown timer expired, executing hard power off",
name()));
diff --git a/monitor/power_off_rule.hpp b/monitor/power_off_rule.hpp
index 3172bd5..ad17870 100644
--- a/monitor/power_off_rule.hpp
+++ b/monitor/power_off_rule.hpp
@@ -84,7 +84,7 @@
{
// Start the action
getLogger().log(
- fmt::format("Starting shutdown action '{}' due to cause '{}'",
+ std::format("Starting shutdown action '{}' due to cause '{}'",
_action->name(), _cause->name()));
_active = true;
@@ -95,13 +95,13 @@
// Attempt to cancel the action, but don't force it
if (_action->cancel(false))
{
- getLogger().log(fmt::format("Stopped shutdown action '{}'",
+ getLogger().log(std::format("Stopped shutdown action '{}'",
_action->name()));
_active = false;
}
else
{
- getLogger().log(fmt::format(
+ getLogger().log(std::format(
"Could not stop shutdown action '{}'", _action->name()));
}
}
diff --git a/monitor/system.cpp b/monitor/system.cpp
index 4a33bb5..bb2e95e 100644
--- a/monitor/system.cpp
+++ b/monitor/system.cpp
@@ -167,7 +167,7 @@
if (serviceObjects.end() == itServ || itServ->second.empty())
{
getLogger().log(
- fmt::format("Fan sensor entry {} not found in D-Bus",
+ std::format("Fan sensor entry {} not found in D-Bus",
sensor->name()),
Logger::error);
continue;
@@ -304,7 +304,7 @@
bool hasOwner = !newOwner.empty() && oldOwner.empty();
std::string stateStr(hasOwner ? "online" : "offline");
- getLogger().log(fmt::format("Changing sensors for service {} to {}",
+ getLogger().log(std::format("Changing sensors for service {} to {}",
serviceName, stateStr),
Logger::info);
@@ -429,7 +429,7 @@
std::string fanPath{util::INVENTORY_PATH + fan.getName()};
getLogger().log(
- fmt::format("Creating event log for faulted fan {} sensor {}", fanPath,
+ std::format("Creating event log for faulted fan {} sensor {}", fanPath,
sensor.name()),
Logger::error);
@@ -473,7 +473,7 @@
std::string fanPath{util::INVENTORY_PATH + fan.getName()};
getLogger().log(
- fmt::format("Creating event log for missing fan {}", fanPath),
+ std::format("Creating event log for missing fan {}", fanPath),
Logger::error);
auto error = std::make_unique<FanError>(
@@ -568,7 +568,7 @@
catch (const std::exception& e)
{
getLogger().log(
- fmt::format("Caught exception while creating BMC dump: {}",
+ std::format("Caught exception while creating BMC dump: {}",
e.what()),
Logger::error);
}
diff --git a/monitor/tach_sensor.cpp b/monitor/tach_sensor.cpp
index 3030d5c..1d92231 100644
--- a/monitor/tach_sensor.cpp
+++ b/monitor/tach_sensor.cpp
@@ -19,12 +19,11 @@
#include "sdbusplus.hpp"
#include "utility.hpp"
-#include <fmt/format.h>
-
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/log.hpp>
#include <filesystem>
+#include <format>
#include <functional>
#include <optional>
#include <utility>
@@ -321,7 +320,7 @@
if (!timerRunning() || mode != _timerMode)
{
log<level::DEBUG>(
- fmt::format("Start timer({}) on tach sensor {}. [delay = {}s]",
+ std::format("Start timer({}) on tach sensor {}. [delay = {}s]",
static_cast<int>(mode), _name,
duration_cast<seconds>(getDelay(mode)).count())
.c_str());
@@ -357,7 +356,7 @@
{
++_counter;
log<level::DEBUG>(
- fmt::format(
+ std::format(
"Incremented error counter on {} to {} (threshold {})",
_name, _counter, _threshold)
.c_str());
@@ -369,7 +368,7 @@
{
--_counter;
log<level::DEBUG>(
- fmt::format(
+ std::format(
"Decremented error counter on {} to {} (threshold {})",
_name, _counter, _threshold)
.c_str());
@@ -382,7 +381,7 @@
if (_countTimer)
{
log<level::DEBUG>(
- fmt::format("Starting count timer on sensor {}", _name).c_str());
+ std::format("Starting count timer on sensor {}", _name).c_str());
_countTimer->restart(std::chrono::seconds(_countInterval));
}
}
@@ -392,7 +391,7 @@
if (_countTimer && _countTimer->isEnabled())
{
log<level::DEBUG>(
- fmt::format("Stopping count timer on tach sensor {}.", _name)
+ std::format("Stopping count timer on tach sensor {}.", _name)
.c_str());
_countTimer->setEnabled(false);
}
diff --git a/monitor/tach_sensor.hpp b/monitor/tach_sensor.hpp
index b4dc5b5..1468ab1 100644
--- a/monitor/tach_sensor.hpp
+++ b/monitor/tach_sensor.hpp
@@ -1,7 +1,5 @@
#pragma once
-#include <fmt/format.h>
-
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/bus/match.hpp>
@@ -11,6 +9,7 @@
#include <chrono>
#include <deque>
+#include <format>
#include <optional>
#include <utility>
@@ -287,7 +286,7 @@
inline void stopTimer()
{
phosphor::logging::log<phosphor::logging::level::DEBUG>(
- fmt::format("Stop running timer on tach sensor {}.", _name)
+ std::format("Stop running timer on tach sensor {}.", _name)
.c_str());
_timer.setEnabled(false);
}
diff --git a/power_state.hpp b/power_state.hpp
index 24b6c9d..478b596 100644
--- a/power_state.hpp
+++ b/power_state.hpp
@@ -2,8 +2,6 @@
#include "sdbusplus.hpp"
-#include <fmt/format.h>
-
#include <phosphor-logging/log.hpp>
#include <xyz/openbmc_project/State/Host/server.hpp>
diff --git a/presence/error_reporter.cpp b/presence/error_reporter.cpp
index 1b46bdf..790a260 100644
--- a/presence/error_reporter.cpp
+++ b/presence/error_reporter.cpp
@@ -20,13 +20,14 @@
#include "psensor.hpp"
#include "utility.hpp"
-#include <fmt/format.h>
#include <unistd.h>
#include <phosphor-logging/log.hpp>
#include <xyz/openbmc_project/Logging/Create/server.hpp>
#include <xyz/openbmc_project/Logging/Entry/server.hpp>
+#include <format>
+
namespace phosphor::fan::presence
{
@@ -108,7 +109,7 @@
present = std::get<bool>(presentProp->second);
if (_fanStates[fanPath] != present)
{
- getLogger().log(fmt::format("Fan {} presence state change to {}",
+ getLogger().log(std::format("Fan {} presence state change to {}",
fanPath, present));
_fanStates[fanPath] = present;
@@ -147,7 +148,7 @@
void ErrorReporter::fanMissingTimerExpired(const std::string& fanPath)
{
getLogger().log(
- fmt::format("Creating event log for missing fan {}", fanPath),
+ std::format("Creating event log for missing fan {}", fanPath),
Logger::error);
std::map<std::string, std::string> additionalData;
@@ -184,7 +185,7 @@
catch (const util::DBusError& e)
{
getLogger().log(
- fmt::format(
+ std::format(
"Call to create an error log for missing fan {} failed: {}",
fanPath, e.what()),
Logger::error);
@@ -208,7 +209,7 @@
if (missing)
{
getLogger().log(
- fmt::format("At power on, there are {} missing fans", missing));
+ std::format("At power on, there are {} missing fans", missing));
}
}
diff --git a/presence/fallback.cpp b/presence/fallback.cpp
index a3c5e72..f301ac1 100644
--- a/presence/fallback.cpp
+++ b/presence/fallback.cpp
@@ -18,11 +18,10 @@
#include "fan.hpp"
#include "psensor.hpp"
-#include <fmt/format.h>
-
#include <phosphor-logging/log.hpp>
#include <algorithm>
+#include <format>
namespace phosphor
{
@@ -54,7 +53,7 @@
++activeSensor;
}
phosphor::logging::log<phosphor::logging::level::INFO>(
- fmt::format("Using backup presence sensor for fan {}",
+ std::format("Using backup presence sensor for fan {}",
std::get<1>(fan))
.c_str());
activeSensor = it;
@@ -92,7 +91,7 @@
if (activeSensor != sensors.begin())
{
phosphor::logging::log<phosphor::logging::level::INFO>(
- fmt::format("Using backup presence sensor for fan {}",
+ std::format("Using backup presence sensor for fan {}",
std::get<1>(fan))
.c_str());
}
diff --git a/presence/gpio.cpp b/presence/gpio.cpp
index 8e4a6d2..ceba1c6 100644
--- a/presence/gpio.cpp
+++ b/presence/gpio.cpp
@@ -109,7 +109,7 @@
ad.emplace("GPIO_DEVICE_PATH", (phys.c_str()));
getLogger().log(
- fmt::format("GPIO presence detect for fan {} said not present but "
+ std::format("GPIO presence detect for fan {} said not present but "
"other methods indicated present",
fanInventoryPath));
try
@@ -121,7 +121,7 @@
catch (const util::DBusError& e)
{
getLogger().log(
- fmt::format("Call to create a {} error for fan {} failed: {}",
+ std::format("Call to create a {} error for fan {} failed: {}",
errorName, fanInventoryPath, e.what()),
Logger::error);
}
diff --git a/presence/json_parser.cpp b/presence/json_parser.cpp
index 5de827d..70cac08 100644
--- a/presence/json_parser.cpp
+++ b/presence/json_parser.cpp
@@ -309,7 +309,7 @@
namespace sdlogging = sdbusplus::xyz::openbmc_project::Logging::server;
log<level::ERR>(
- fmt::format(
+ std::format(
"Error creating Gpio device bridge, hardware not detected: {}",
e.what())
.c_str());
@@ -331,7 +331,7 @@
}
catch (const util::DBusError& e)
{
- log<level::ERR>(fmt::format("Call to create an error log for "
+ log<level::ERR>(std::format("Call to create an error log for "
"presence-sensor failure failed: {}",
e.what())
.c_str());
diff --git a/presence/tach.cpp b/presence/tach.cpp
index 9fa8256..9f6e105 100644
--- a/presence/tach.cpp
+++ b/presence/tach.cpp
@@ -18,10 +18,9 @@
#include "logging.hpp"
#include "rpolicy.hpp"
-#include <fmt/format.h>
-
#include <phosphor-logging/log.hpp>
+#include <format>
#include <string>
#include <tuple>
#include <vector>
@@ -75,7 +74,7 @@
std::get<double>(s) = 0;
log<level::INFO>(
- fmt::format("Unable to read fan tach sensor {}", tachPath)
+ std::format("Unable to read fan tach sensor {}", tachPath)
.c_str());
}
}
@@ -144,7 +143,7 @@
void Tach::logConflict(const std::string& fanInventoryPath) const
{
- getLogger().log(fmt::format(
+ getLogger().log(std::format(
"Tach sensor presence detect for fan {} said not present but "
"other methods indicated present",
fanInventoryPath));
diff --git a/sdbusplus.hpp b/sdbusplus.hpp
index a5fae30..9627e40 100644
--- a/sdbusplus.hpp
+++ b/sdbusplus.hpp
@@ -1,7 +1,5 @@
#pragma once
-#include <fmt/format.h>
-
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/log.hpp>
@@ -10,6 +8,8 @@
#include <sdbusplus/message.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <format>
+
namespace phosphor
{
namespace fan
@@ -47,7 +47,7 @@
public:
DBusMethodError(const std::string& busName, const std::string& path,
const std::string& interface, const std::string& method) :
- DBusError(fmt::format("DBus method failed: {} {} {} {}", busName, path,
+ DBusError(std::format("DBus method failed: {} {} {} {}", busName, path,
interface, method)),
busName(busName), path(path), interface(interface), method(method)
{}
@@ -69,7 +69,7 @@
public:
DBusServiceError(const std::string& path, const std::string& interface) :
DBusError(
- fmt::format("DBus service lookup failed: {} {}", path, interface)),
+ std::format("DBus service lookup failed: {} {}", path, interface)),
path(path), interface(interface)
{}
@@ -88,7 +88,7 @@
DBusPropertyError(const std::string& msg, const std::string& busName,
const std::string& path, const std::string& interface,
const std::string& property) :
- DBusError(msg + fmt::format(": {} {} {} {}", busName, path, interface,
+ DBusError(msg + std::format(": {} {} {} {}", busName, path, interface,
property)),
busName(busName), path(path), interface(interface), property(property)
{}
diff --git a/sensor-monitor/alarm_timestamps.hpp b/sensor-monitor/alarm_timestamps.hpp
index e25d9fc..b5889a9 100644
--- a/sensor-monitor/alarm_timestamps.hpp
+++ b/sensor-monitor/alarm_timestamps.hpp
@@ -18,8 +18,6 @@
#include "types.hpp"
-#include <fmt/format.h>
-
#include <cereal/archives/json.hpp>
#include <cereal/types/string.hpp>
#include <cereal/types/tuple.hpp>
@@ -29,6 +27,7 @@
#include <sdeventplus/utility/timer.hpp>
#include <filesystem>
+#include <format>
#include <fstream>
#include <map>
#include <tuple>
@@ -247,7 +246,7 @@
std::error_code ec;
std::filesystem::remove(path, ec);
log<level::ERR>(
- fmt::format("Unable to restore persisted times ({}, ec: {})",
+ std::format("Unable to restore persisted times ({}, ec: {})",
e.what(), ec.value())
.c_str());
}
diff --git a/sensor-monitor/shutdown_alarm_monitor.cpp b/sensor-monitor/shutdown_alarm_monitor.cpp
index 0828b16..05692c0 100644
--- a/sensor-monitor/shutdown_alarm_monitor.cpp
+++ b/sensor-monitor/shutdown_alarm_monitor.cpp
@@ -17,12 +17,13 @@
#include "shutdown_alarm_monitor.hpp"
-#include <fmt/format.h>
#include <unistd.h>
#include <phosphor-logging/log.hpp>
#include <xyz/openbmc_project/Logging/Entry/server.hpp>
+#include <format>
+
namespace sensor::monitor
{
using namespace phosphor::logging;
@@ -159,7 +160,7 @@
catch (const DBusServiceError& e)
{
// The sensor isn't on D-Bus anymore
- log<level::INFO>(fmt::format("No {} interface on {} anymore.",
+ log<level::INFO>(std::format("No {} interface on {} anymore.",
interface, sensorPath)
.c_str());
continue;
@@ -280,7 +281,7 @@
{
const uint64_t& original = previousStartTime->second;
- log<level::INFO>(fmt::format("Found previously running {} timer "
+ log<level::INFO>(std::format("Found previously running {} timer "
"for {} with start time {}",
propertyName, sensorPath, original)
.c_str());
@@ -302,7 +303,7 @@
else
{
log<level::WARNING>(
- fmt::format(
+ std::format(
"Restarting {} shutdown timer for {} for full "
"time because saved time {} is after current time {}",
propertyName, sensorPath, original, now)
@@ -311,7 +312,7 @@
}
log<level::INFO>(
- fmt::format("Starting {}ms {} shutdown timer due to sensor {} value {}",
+ std::format("Starting {}ms {} shutdown timer due to sensor {} value {}",
shutdownDelay.count(), propertyName, sensorPath, *value)
.c_str());
@@ -345,7 +346,7 @@
createEventLog(alarmKey, false, value);
log<level::INFO>(
- fmt::format("Stopping {} shutdown timer due to sensor {} value {}",
+ std::format("Stopping {} shutdown timer due to sensor {} value {}",
propertyName, sensorPath, value)
.c_str());
@@ -368,7 +369,7 @@
}
catch (const std::exception& e)
{
- auto message = fmt::format(
+ auto message = std::format(
"Caught exception while creating BMC dump: {}", e.what());
log<level::ERR>(message.c_str());
@@ -384,7 +385,7 @@
valueProperty);
log<level::ERR>(
- fmt::format(
+ std::format(
"The {} shutdown timer expired for sensor {}, shutting down",
propertyName, sensorPath)
.c_str());
diff --git a/sensor-monitor/threshold_alarm_logger.cpp b/sensor-monitor/threshold_alarm_logger.cpp
index 99ed0d6..13058e7 100644
--- a/sensor-monitor/threshold_alarm_logger.cpp
+++ b/sensor-monitor/threshold_alarm_logger.cpp
@@ -17,12 +17,13 @@
#include "sdbusplus.hpp"
-#include <fmt/format.h>
#include <unistd.h>
#include <phosphor-logging/log.hpp>
#include <xyz/openbmc_project/Logging/Entry/server.hpp>
+#include <format>
+
namespace sensor::monitor
{
@@ -284,7 +285,7 @@
if (properties == it->second.end())
{
log<level::INFO>(
- fmt::format("Could not find {} in threshold alarms map",
+ std::format("Could not find {} in threshold alarms map",
alarmProperty)
.c_str());
return;
@@ -301,7 +302,7 @@
ad.emplace("SENSOR_VALUE", std::to_string(sensorValue));
log<level::INFO>(
- fmt::format("Threshold Event {} {} = {} (sensor value {})",
+ std::format("Threshold Event {} {} = {} (sensor value {})",
sensorPath, alarmProperty, alarmValue, sensorValue)
.c_str());
}
@@ -311,7 +312,7 @@
// not be in the mapper yet. This could only happen if the sensor
// application was started up after this one and the value exceeded the
// threshold immediately.
- log<level::INFO>(fmt::format("Threshold Event {} {} = {}", sensorPath,
+ log<level::INFO>(std::format("Threshold Event {} {} = {}", sensorPath,
alarmProperty, alarmValue)
.c_str());
}
@@ -341,7 +342,7 @@
if ((sensorPath.back() == '/') || (pos == std::string::npos))
{
log<level::ERR>(
- fmt::format("Cannot get sensor type from sensor path {}",
+ std::format("Cannot get sensor type from sensor path {}",
sensorPath)
.c_str());
throw std::runtime_error("Invalid sensor path");
diff --git a/utility.hpp b/utility.hpp
index cbf6205..727b557 100644
--- a/utility.hpp
+++ b/utility.hpp
@@ -1,7 +1,6 @@
#pragma once
#include <fcntl.h>
-#include <fmt/format.h>
#include <unistd.h>
#include <phosphor-logging/elog-errors.hpp>
@@ -10,6 +9,8 @@
#include <sdbusplus/bus.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <format>
+
using namespace phosphor::logging;
using InternalFailure =
sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
@@ -66,7 +67,7 @@
if (-1 == fd)
{
log<level::ERR>(
- fmt::format("Failed to open file device path {}", pathname)
+ std::format("Failed to open file device path {}", pathname)
.c_str());
elog<InternalFailure>();
}