Use std::string_view and fmtlib across all libraries (#3402)

- Twine, StringRef, Format, and NativeFormatting have been removed
- Logging now uses fmtlib style formatting
- Nearly all uses of wpi::outs/errs have been replaced with fmt::print() or
std::puts()/std::fputs() (for unformatted strings).
- A wpi/fmt/raw_ostream.h header has been added to enable
fmt::print() with wpi::raw_ostream
This commit is contained in:
Peter Johnson
2021-06-06 16:13:58 -07:00
committed by GitHub
parent 4f1cecb8e7
commit b2c3b2dd8e
441 changed files with 5061 additions and 9749 deletions

View File

@@ -4,8 +4,8 @@
#include "HALSimWeb.h"
#include <fmt/format.h>
#include <wpi/SmallString.h>
#include <wpi/Twine.h>
#include <wpi/UrlParser.h>
#include <wpi/WebSocketServer.h>
#include <wpi/fs.h>
@@ -25,7 +25,7 @@ HALSimWeb::HALSimWeb(wpi::uv::Loop& loop, ProviderContainer& providers,
m_providers(providers),
m_simDevicesProvider(simDevicesProvider) {
m_loop.error.connect([](uv::Error err) {
wpi::errs() << "HALSim WS Server libuv ERROR: " << err.str() << '\n';
fmt::print(stderr, "HALSim WS Server libuv ERROR: {}\n", err.str());
});
m_server = uv::Tcp::Create(m_loop);
@@ -70,7 +70,7 @@ bool HALSimWeb::Initialize() {
try {
m_port = std::stoi(port);
} catch (const std::invalid_argument& err) {
wpi::errs() << "Error decoding HALSIMWS_PORT (" << err.what() << ")\n";
fmt::print(stderr, "Error decoding HALSIMWS_PORT ({})\n", err.what());
return false;
}
} else {
@@ -98,8 +98,8 @@ void HALSimWeb::Start() {
// start listening for incoming connections
m_server->Listen();
wpi::outs() << "Listening at http://localhost:" << m_port << "\n";
wpi::outs() << "WebSocket URI: " << m_uri << "\n";
fmt::print("Listening at http://localhost:{}\n", m_port);
fmt::print("WebSocket URI: {}\n", m_uri);
}
bool HALSimWeb::RegisterWebsocket(
@@ -154,6 +154,6 @@ void HALSimWeb::OnNetValueChanged(const wpi::json& msg) {
provider->OnNetValueChanged(msg.at("data"));
}
} catch (wpi::json::exception& e) {
wpi::errs() << "Error with incoming message: " << e.what() << "\n";
fmt::print(stderr, "Error with incoming message: {}\n", e.what());
}
}