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/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(),