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)};
}
}