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