[wpiutil] Upgrade to fmt 10.2.1, add wpi::print (#6161)

We now use a wrapper (wpi::print) to catch exceptions since we can't patch
std::print() to not throw when we ultimately migrate to it.

fmtlib and std format/print throw the same exceptions and always have. We previously patched fmt::print() to not throw a write failure exception, but we can't do that for std::print(); wpi::print() is the migration plan.
This commit is contained in:
Tyler Veness
2024-05-12 06:25:42 -07:00
committed by GitHub
parent 6c9dcc157e
commit d88c71ffdc
99 changed files with 1374 additions and 1130 deletions

View File

@@ -6,8 +6,8 @@
#include <utility>
#include <fmt/format.h>
#include <wpi/StringExtras.h>
#include <wpi/print.h>
using namespace glass;
@@ -36,7 +36,7 @@ void DataLogReaderThread::ReadMain() {
std::scoped_lock lock{m_mutex};
auto& entryPtr = m_entriesById[data.entry];
if (entryPtr) {
fmt::print("...DUPLICATE entry ID, overriding\n");
wpi::print("...DUPLICATE entry ID, overriding\n");
}
auto [it, isNew] = m_entriesByName.emplace(data.name, data);
if (isNew) {
@@ -50,7 +50,7 @@ void DataLogReaderThread::ReadMain() {
}
sigEntryAdded(data);
} else {
fmt::print("Start(INVALID)\n");
wpi::print("Start(INVALID)\n");
}
} else if (record.IsFinish()) {
int entry;
@@ -58,13 +58,13 @@ void DataLogReaderThread::ReadMain() {
std::scoped_lock lock{m_mutex};
auto it = m_entriesById.find(entry);
if (it == m_entriesById.end()) {
fmt::print("...ID not found\n");
wpi::print("...ID not found\n");
} else {
it->second->ranges.back().m_end = recordIt;
m_entriesById.erase(it);
}
} else {
fmt::print("Finish(INVALID)\n");
wpi::print("Finish(INVALID)\n");
}
} else if (record.IsSetMetadata()) {
wpi::log::MetadataRecordData data;
@@ -72,15 +72,15 @@ void DataLogReaderThread::ReadMain() {
std::scoped_lock lock{m_mutex};
auto it = m_entriesById.find(data.entry);
if (it == m_entriesById.end()) {
fmt::print("...ID not found\n");
wpi::print("...ID not found\n");
} else {
it->second->metadata = data.metadata;
}
} else {
fmt::print("SetMetadata(INVALID)\n");
wpi::print("SetMetadata(INVALID)\n");
}
} else if (record.IsControl()) {
fmt::print("Unrecognized control record\n");
wpi::print("Unrecognized control record\n");
} else {
auto it = schemaEntries.find(record.GetEntry());
if (it != schemaEntries.end()) {
@@ -106,14 +106,14 @@ void DataLogReaderThread::ReadMain() {
std::string err;
auto desc = m_structDb.Add(typeStr, schema, &err);
if (!desc) {
fmt::print("could not decode struct '{}' schema '{}': {}\n", name,
wpi::print("could not decode struct '{}' schema '{}': {}\n", name,
schema, err);
}
} else if (wpi::starts_with(name, "/.schema/proto:")) {
// protobuf descriptor handling
auto filename = wpi::drop_front(name, 15);
if (!m_protoDb.Add(filename, data)) {
fmt::print("could not decode protobuf '{}' filename '{}'\n", name,
wpi::print("could not decode protobuf '{}' filename '{}'\n", name,
filename);
}
}