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