cleanup fmt::format for std::format
Update the code to use std::format since gcc13 supports it now. Also
cleaned up some unused headers.
Change-Id: Ief2ad4df9e8b8227168f4f98213da8b3978fda03
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/subprojects/nemora-postd/src/host_manager.cpp b/subprojects/nemora-postd/src/host_manager.cpp
index eb0a2b9..b771146 100644
--- a/subprojects/nemora-postd/src/host_manager.cpp
+++ b/subprojects/nemora-postd/src/host_manager.cpp
@@ -14,17 +14,14 @@
#include "host_manager.hpp"
-#include <fmt/format.h>
-
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/message.hpp>
+#include <format>
#include <functional>
-#include <iostream>
#include <variant>
-using fmt::format;
using phosphor::logging::level;
using phosphor::logging::log;
@@ -79,7 +76,7 @@
auto count = postcodes_.size();
if (count > 0)
{
- std::string msg = format("Draining Postcodes. Count: {}.", count);
+ std::string msg = std::format("Draining Postcodes. Count: {}.", count);
log<level::ERR>(msg.c_str());
}
diff --git a/subprojects/nemora-postd/src/serializer.cpp b/subprojects/nemora-postd/src/serializer.cpp
index 69324d9..f87d6d2 100644
--- a/subprojects/nemora-postd/src/serializer.cpp
+++ b/subprojects/nemora-postd/src/serializer.cpp
@@ -16,11 +16,10 @@
#include "event_message.pb.h"
-#include <fmt/format.h>
-
#include <phosphor-logging/log.hpp>
-using fmt::format;
+#include <format>
+
using phosphor::logging::level;
using phosphor::logging::log;
@@ -34,9 +33,9 @@
break;
default:
log<level::ERR>(
- format("Type with ID {} not supported by "
- "Serializer::Serialize(const NemoraDatagram*)",
- static_cast<int>(dgram->type))
+ std::format("Type with ID {} not supported by "
+ "Serializer::Serialize(const NemoraDatagram*)",
+ static_cast<int>(dgram->type))
.c_str());
}
@@ -64,7 +63,7 @@
platforms::nemora::proto::EventSeries::NATIVE_32_BIT);
log<level::INFO>(
- format("NemoraEvent {}", pb.DebugString().c_str()).c_str());
+ std::format("NemoraEvent {}", pb.DebugString().c_str()).c_str());
pb.SerializeToString(&result);
return result;
}
diff --git a/subprojects/nemora-postd/src/socket_manager.cpp b/subprojects/nemora-postd/src/socket_manager.cpp
index 13f3269..884e1d6 100644
--- a/subprojects/nemora-postd/src/socket_manager.cpp
+++ b/subprojects/nemora-postd/src/socket_manager.cpp
@@ -17,15 +17,14 @@
#include "serializer.hpp"
#include <errno.h>
-#include <fmt/format.h>
#include <sys/socket.h>
#include <unistd.h>
#include <phosphor-logging/log.hpp>
#include <cstring>
+#include <format>
-using fmt::format;
using phosphor::logging::level;
using phosphor::logging::log;
@@ -59,10 +58,11 @@
sizeof(bcast->destination6));
if (err < 0)
{
- log<level::ERR>(format("SocketManager::SendDatagram: Couldn't sendto "
- "socket (IPv6): {}",
- std::strerror(errno))
- .c_str());
+ log<level::ERR>(
+ std::format("SocketManager::SendDatagram: Couldn't sendto "
+ "socket (IPv6): {}",
+ std::strerror(errno))
+ .c_str());
}
// Send serialized data (v4)
@@ -71,10 +71,11 @@
sizeof(bcast->destination));
if (err < 0)
{
- log<level::ERR>(format("SocketManager::SendDatagram: Couldn't sendto "
- "socket (IPv4): {}",
- std::strerror(errno))
- .c_str());
+ log<level::ERR>(
+ std::format("SocketManager::SendDatagram: Couldn't sendto "
+ "socket (IPv4): {}",
+ std::strerror(errno))
+ .c_str());
}
CloseSocketSafely(fd);