Remove remaining fmt::format use
The only remaining use of the fmt::format library was for something
std::format can't yet handle, printing ranges. This was only used
twice, in the same file, so just manually build up the vectors in
question into a string and use std::format. This was already being done
in other places anyway.
Now the fmt::format subproject and dependencies can be completely
removed.
An added benefit is that those two fmt::format calls were failing to
build on my system when I was trying to build using subprojects, and
without them everything works.
Tested:
Can still see the traces, though I only have a 1 element vector to test
with:
Adding fan target lock of 11300 on fans [fan0] zone 0",
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I90055e9d1c8d0b79b151e1cfd0af2052005cef3c
diff --git a/control/json/actions/override_fan_target.cpp b/control/json/actions/override_fan_target.cpp
index c5e15ad..33fbd34 100644
--- a/control/json/actions/override_fan_target.cpp
+++ b/control/json/actions/override_fan_target.cpp
@@ -20,11 +20,10 @@
#include "action.hpp"
#include "group.hpp"
-#include <fmt/format.h>
-#include <fmt/ranges.h>
-
#include <nlohmann/json.hpp>
+#include <format>
+
namespace phosphor::fan::control::json
{
@@ -83,8 +82,17 @@
{
if (!_locked)
{
- record(fmt::format("Adding fan target lock of {} on fans {} zone {}",
- _target, _fans, zone.getName()));
+ std::string fanList;
+ if (!_fans.empty())
+ {
+ fanList = std::accumulate(std::next(_fans.begin()), _fans.end(),
+ _fans[0], [](auto list, auto fan) {
+ return std::move(list) + ", " + fan;
+ });
+ }
+
+ record(std::format("Adding fan target lock of {} on fans [{}] zone {}",
+ _target, fanList, zone.getName()));
for (auto& fan : _fans)
{
@@ -97,8 +105,16 @@
void OverrideFanTarget::unlockFans(Zone& zone)
{
- record(fmt::format("Un-locking fan target {} on fans {} zone {}", _target,
- _fans, zone.getName()));
+ std::string fanList;
+ if (!_fans.empty())
+ {
+ fanList = std::accumulate(
+ std::next(_fans.begin()), _fans.end(), _fans[0],
+ [](auto list, auto fan) { return std::move(list) + ", " + fan; });
+ }
+
+ record(std::format("Un-locking fan target {} on fans [{}] zone {}", _target,
+ fanList, zone.getName()));
// unlock all fans in this instance
for (auto& fan : _fans)