switch fmt::format to use std::format
The fmt::format is supported directly in std now. Swap it out and
remove the unnecessary dependency.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ie278c6328239928198fd87f5007468d401e44a21
diff --git a/watchdog/ffdc_file.cpp b/watchdog/ffdc_file.cpp
index 0086e2f..bcc016f 100644
--- a/watchdog/ffdc_file.cpp
+++ b/watchdog/ffdc_file.cpp
@@ -2,13 +2,13 @@
#include <errno.h> // for errno
#include <fcntl.h> // for open()
-#include <fmt/format.h>
#include <string.h> // for strerror()
#include <sys/stat.h> // for open()
#include <sys/types.h> // for open()
#include <phosphor-logging/log.hpp>
+#include <format>
#include <stdexcept>
#include <string>
@@ -29,7 +29,7 @@
// Close file descriptor. Does nothing if descriptor was already closed.
if (descriptor.close() == -1)
{
- log<level::ERR>(fmt::format("Unable to close FFDC file: errormsg({})",
+ log<level::ERR>(std::format("Unable to close FFDC file: errormsg({})",
strerror(errno))
.c_str());
}
@@ -52,7 +52,7 @@
if (rc == -1)
{
- log<level::ERR>(fmt::format("Failed to write callout info "
+ log<level::ERR>(std::format("Failed to write callout info "
"in file({}), errorno({}), errormsg({})",
tempFile.getPath().c_str(), errno,
strerror(errno))
@@ -61,7 +61,7 @@
}
else if (rc != static_cast<ssize_t>(calloutData.size()))
{
- log<level::WARNING>(fmt::format("Could not write all callout "
+ log<level::WARNING>(std::format("Could not write all callout "
"info in file({}), written byte({}) "
"and total byte({})",
tempFile.getPath().c_str(), rc,
@@ -74,7 +74,7 @@
if (retCode == -1)
{
log<level::ERR>(
- fmt::format("Failed to seek file postion to the beginning"
+ std::format("Failed to seek file postion to the beginning"
"in file({}), errorno({}) "
"and errormsg({})",
tempFile.getPath().c_str(), errno, strerror(errno))
diff --git a/watchdog/watchdog_dbus.cpp b/watchdog/watchdog_dbus.cpp
index 4512ab0..1606be1 100644
--- a/watchdog/watchdog_dbus.cpp
+++ b/watchdog/watchdog_dbus.cpp
@@ -1,10 +1,10 @@
-#include <fmt/format.h>
#include <unistd.h>
#include <phosphor-logging/log.hpp>
#include <watchdog_dbus.hpp>
#include <watchdog_logging.hpp>
+#include <format>
#include <string>
#include <vector>
@@ -160,7 +160,7 @@
catch (const sdbusplus::exception_t& e)
{
log<level::ERR>(
- fmt::format("Failed to read CurrentHostState property ({})",
+ std::format("Failed to read CurrentHostState property ({})",
e.what())
.c_str());
}
diff --git a/watchdog/watchdog_handler.cpp b/watchdog/watchdog_handler.cpp
index 78008ac..c4afb2a 100644
--- a/watchdog/watchdog_handler.cpp
+++ b/watchdog/watchdog_handler.cpp
@@ -1,5 +1,3 @@
-#include <fmt/format.h>
-
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/bus/match.hpp>
@@ -7,6 +5,8 @@
#include <watchdog_handler.hpp>
#include <watchdog_logging.hpp>
+#include <format>
+
namespace watchdog
{
namespace dump
@@ -173,7 +173,7 @@
{
// Dump is disabled, Skip the dump collection.
log<level::INFO>(
- fmt::format(
+ std::format(
"Dump is disabled on({}), skipping dump collection",
dumpParameters.unitId)
.c_str());
@@ -181,7 +181,7 @@
else
{
log<level::ERR>(
- fmt::format("D-Bus call createDump exception ",
+ std::format("D-Bus call createDump exception ",
"OBJPATH={}, INTERFACE={}, EXCEPTION={}", path,
interface, e.what())
.c_str());
diff --git a/watchdog/watchdog_main.cpp b/watchdog/watchdog_main.cpp
index 00f7830..7ad1ced 100644
--- a/watchdog/watchdog_main.cpp
+++ b/watchdog/watchdog_main.cpp
@@ -1,4 +1,4 @@
-#include <fmt/format.h>
+#include <format>
extern "C"
{
#include <libpdbg.h>
@@ -71,7 +71,7 @@
}
catch (const std::exception& e)
{
- log<level::ERR>(fmt::format("getLocationCode({}): Exception({})",
+ log<level::ERR>(std::format("getLocationCode({}): Exception({})",
pdbg_target_path(procTarget), e.what())
.c_str());
}
@@ -93,7 +93,7 @@
{
// Failed to collect FFDC information
log<level::ERR>(
- fmt::format("captureFFDC: Exception{}", e.what()).c_str());
+ std::format("captureFFDC: Exception{}", e.what()).c_str());
dumpIsRequired = true;
}
@@ -157,7 +157,7 @@
catch (const std::exception& e)
{
log<level::ERR>(
- fmt::format("Skipping SBE special callout due to Exception({})",
+ std::format("Skipping SBE special callout due to Exception({})",
e.what())
.c_str());
}
@@ -182,7 +182,7 @@
catch (const std::exception& e)
{
log<level::ERR>(
- fmt::format("Exception {} occurred", e.what()).c_str());
+ std::format("Exception {} occurred", e.what()).c_str());
return;
}