diff --git a/CMakeLists.txt b/CMakeLists.txt index f4d4c7f49..3c64604d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,7 +72,6 @@ find_package(OpenMP) find_package(Opal) find_package(IBVerbs) find_package(RDMACM) -find_package(spdlog) find_package(Etherlab) find_package(Lua) find_package(LibDataChannel) diff --git a/common b/common index 08fd24b85..785d94cac 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 08fd24b85ec4e5b18f370702eb129b4f1d1e4bca +Subproject commit 785d94caccc1e43853439cb6bd1e1c170fff42a9 diff --git a/fpga b/fpga index 1cac3fafd..4e59f0d04 160000 --- a/fpga +++ b/fpga @@ -1 +1 @@ -Subproject commit 1cac3fafde6ef3098a145f9d5d936a2dc6b7d7c0 +Subproject commit 4e59f0d04bfe5f741b5a1345c858fa0074190f5d diff --git a/include/villas/node.hpp b/include/villas/node.hpp index 73c7dd491..80343e32b 100644 --- a/include/villas/node.hpp +++ b/include/villas/node.hpp @@ -7,8 +7,8 @@ #pragma once +#include #include -#include #include #include @@ -25,6 +25,10 @@ #include #include +#ifndef FMT_LEGACY_OSTREAM_FORMATTER +#include +#endif + #if defined(LIBNL3_ROUTE_FOUND) && defined(__linux__) #define WITH_NETEM #endif // LIBNL3_ROUTE_FOUND @@ -260,9 +264,7 @@ public: void setEnabled(bool en) { enabled = en; } - // Custom formatter for spdlog - template - friend OStream &operator<<(OStream &os, const Node &n) { + friend std::ostream &operator<<(std::ostream &os, const Node &n) { os << n.getName(); return os; @@ -317,9 +319,7 @@ public: virtual std::string getType() const { return "node"; } - // Custom formatter for spdlog - template - friend OStream &operator<<(OStream &os, const NodeFactory &f) { + friend std::ostream &operator<<(std::ostream &os, const NodeFactory &f) { os << f.getName(); return os; @@ -366,3 +366,11 @@ public: } // namespace node } // namespace villas + +#ifndef FMT_LEGACY_OSTREAM_FORMATTER +template <> +class fmt::formatter : public fmt::ostream_formatter {}; +template <> +class fmt::formatter + : public fmt::ostream_formatter {}; +#endif diff --git a/include/villas/node_compat_type.hpp b/include/villas/node_compat_type.hpp index 72877456b..86c47b553 100644 --- a/include/villas/node_compat_type.hpp +++ b/include/villas/node_compat_type.hpp @@ -8,7 +8,6 @@ #pragma once #include -#include #include #include diff --git a/include/villas/nodes/redis.hpp b/include/villas/nodes/redis.hpp index ab9b43c4d..33710dcab 100644 --- a/include/villas/nodes/redis.hpp +++ b/include/villas/nodes/redis.hpp @@ -26,6 +26,25 @@ namespace node { enum class RedisMode { KEY, HASH, CHANNEL }; +inline std::ostream &operator<<(std::ostream &os, const enum villas::node::RedisMode &m) { + switch (m) { + case villas::node::RedisMode::KEY: + os << "key"; + break; + + case villas::node::RedisMode::HASH: + os << "hash"; + break; + + case villas::node::RedisMode::CHANNEL: + os << "channel"; + break; + } + + return os; +} + + class RedisConnection { public: diff --git a/include/villas/nodes/redis_helpers.hpp b/include/villas/nodes/redis_helpers.hpp index 701bde7ec..292c5f423 100644 --- a/include/villas/nodes/redis_helpers.hpp +++ b/include/villas/nodes/redis_helpers.hpp @@ -9,11 +9,14 @@ #include #include -#include +#include #include - #include +#ifndef FMT_LEGACY_OSTREAM_FORMATTER +#include +#endif + namespace std { template @@ -52,7 +55,7 @@ template <> struct hash { namespace sw { namespace redis { -bool operator==(const tls::TlsOptions &o1, const tls::TlsOptions &o2) { +inline bool operator==(const tls::TlsOptions &o1, const tls::TlsOptions &o2) { #ifdef REDISPP_WITH_TLS return o1.enabled == o2.enabled && o1.cacert == o2.cacert && o1.cacertdir == o2.cacertdir && o1.cert == o2.cert && @@ -62,7 +65,7 @@ bool operator==(const tls::TlsOptions &o1, const tls::TlsOptions &o2) { #endif // REDISPP_WITH_TLS } -bool operator==(const ConnectionOptions &o1, const ConnectionOptions &o2) { +inline bool operator==(const ConnectionOptions &o1, const ConnectionOptions &o2) { return o1.type == o2.type && o1.host == o2.host && o1.port == o2.port && o1.path == o2.path && o1.user == o2.user && o1.password == o2.password && o1.db == o2.db && @@ -72,8 +75,8 @@ bool operator==(const ConnectionOptions &o1, const ConnectionOptions &o2) { } #ifdef REDISPP_WITH_TLS -template -OStream &operator<<(OStream &os, const tls::TlsOptions &t) { +namespace tls { +std::ostream &operator<<(std::ostream &os, const TlsOptions &t) { os << "tls.enabled=" << (t.enabled ? "yes" : "no"); if (t.enabled) { @@ -95,10 +98,10 @@ OStream &operator<<(OStream &os, const tls::TlsOptions &t) { return os; } +} #endif // REDISPP_WITH_TLS -template -OStream &operator<<(OStream &os, const ConnectionType &t) { +inline std::ostream &operator<<(std::ostream &os, const ConnectionType &t) { switch (t) { case ConnectionType::TCP: os << "tcp"; @@ -112,8 +115,7 @@ OStream &operator<<(OStream &os, const ConnectionType &t) { return os; } -template -OStream &operator<<(OStream &os, const ConnectionOptions &o) { +inline std::ostream &operator<<(std::ostream &os, const ConnectionOptions &o) { os << "type=" << o.type; switch (o.type) { @@ -139,36 +141,31 @@ OStream &operator<<(OStream &os, const ConnectionOptions &o) { } // namespace redis } // namespace sw -template -OStream &operator<<(OStream &os, const enum villas::node::RedisMode &m) { - switch (m) { - case villas::node::RedisMode::KEY: - os << "key"; - break; - - case villas::node::RedisMode::HASH: - os << "hash"; - break; - - case villas::node::RedisMode::CHANNEL: - os << "channel"; - break; - } - - return os; -} - namespace villas { namespace node { #ifdef REDISPP_WITH_URI -sw::redis::ConnectionOptions make_redis_connection_options(char const *uri) { +inline sw::redis::ConnectionOptions make_redis_connection_options(char const *uri) { auto u = sw::redis::Uri{uri}; return u.connection_options(); } #else -sw::redis::ConnectionOptions make_redis_connection_options(char const *uri) { +inline sw::redis::ConnectionOptions make_redis_connection_options(char const *uri) { return sw::redis::ConnectionOptions{uri}; } #endif } // namespace node } // namespace villas + +#ifndef FMT_LEGACY_OSTREAM_FORMATTER +template <> +class fmt::formatter + : public fmt::ostream_formatter {}; +template <> +class fmt::formatter + : public fmt::ostream_formatter {}; +#ifdef REDISPP_WITH_TLS +template <> +class fmt::formatter + : public fmt::ostream_formatter {}; +#endif +#endif diff --git a/include/villas/nodes/webrtc/peer_connection.hpp b/include/villas/nodes/webrtc/peer_connection.hpp index 26fb62d74..47f246413 100644 --- a/include/villas/nodes/webrtc/peer_connection.hpp +++ b/include/villas/nodes/webrtc/peer_connection.hpp @@ -9,7 +9,9 @@ #pragma once +#include #include +#include #include #include @@ -17,6 +19,32 @@ #include #include +#ifndef FMT_LEGACY_OSTREAM_FORMATTER +#include +#endif + +/* + * libdatachannel defines the operator<< overloads required to format + * rtc::PeerConnection::State and similar in the global namespace. + * But C++ ADL based overload set construction does not find these operators, + * if these are invoked in the spdlog/fmt libraries. + * + * See this issue for a short explaination of ADL errors: + * https://github.com/gabime/spdlog/issues/1227#issuecomment-532009129 + * + * Adding the global ::operator<< overload set to the namespace rtc where + * the data structures are defined, allows ADL to pick these up in spdlog/fmt. + */ +namespace rtc { +using ::operator<<; +} + +#ifndef FMT_LEGACY_OSTREAM_FORMATTER +template <> +class fmt::formatter + : public fmt::ostream_formatter {}; +#endif + namespace villas { namespace node { namespace webrtc { diff --git a/include/villas/nodes/websocket.hpp b/include/villas/nodes/websocket.hpp index d7f91471e..d3791399e 100644 --- a/include/villas/nodes/websocket.hpp +++ b/include/villas/nodes/websocket.hpp @@ -8,7 +8,6 @@ #pragma once #include -#include #include #include @@ -19,6 +18,10 @@ #include #include +#ifndef FMT_LEGACY_OSTREAM_FORMATTER +#include +#endif + // Forward declarations struct lws; @@ -75,9 +78,7 @@ struct websocket_connection { *send; // A buffer for constructing messages before calling lws_write() } buffers; - // Custom formatter for spdlog - template - friend OStream &operator<<(OStream &os, + friend std::ostream &operator<<(std::ostream &os, const struct websocket_connection &c) { if (c.wsi) { char name[128]; @@ -133,3 +134,9 @@ int websocket_write(NodeCompat *n, struct Sample *const smps[], unsigned cnt); } // namespace node } // namespace villas + +#ifndef FMT_LEGACY_OSTREAM_FORMATTER +template <> +class fmt::formatter + : public fmt::ostream_formatter {}; +#endif diff --git a/include/villas/path.hpp b/include/villas/path.hpp index 90e06b499..b4fc97b33 100644 --- a/include/villas/path.hpp +++ b/include/villas/path.hpp @@ -11,7 +11,6 @@ #include #include -#include #include #include @@ -26,9 +25,12 @@ #include #include #include - #include +#ifndef FMT_LEGACY_OSTREAM_FORMATTER +#include +#endif + // Forward declarations struct pollfd; @@ -99,9 +101,7 @@ public: std::bitset received; // A mask of PathSources for which we already received samples. - // Custom formatter for spdlog - template - friend OStream &operator<<(OStream &os, const Path &p) { + friend std::ostream &operator<<(std::ostream &os, const Path &p) { if (p.sources.size() > 1) os << "[ "; @@ -185,3 +185,9 @@ public: } // namespace node } // namespace villas + +#ifndef FMT_LEGACY_OSTREAM_FORMATTER +template <> +class fmt::formatter + : public fmt::ostream_formatter {}; +#endif diff --git a/lib/hooks/limit_rate.cpp b/lib/hooks/limit_rate.cpp index 80cf00b22..65075e06b 100644 --- a/lib/hooks/limit_rate.cpp +++ b/lib/hooks/limit_rate.cpp @@ -39,7 +39,7 @@ void LimitRateHook::parse(json_t *json) { mode = LIMIT_RATE_LOCAL; else throw ConfigError(json, "node-config-hook-limit_rate-mode", - "Invalid value '{}' for setting 'mode'", mode); + "Invalid value '{}' for setting 'mode'", m); } deadtime = 1.0 / rate; diff --git a/lib/nodes/iec60870.cpp b/lib/nodes/iec60870.cpp index a05ee4890..87f9cbbdc 100644 --- a/lib/nodes/iec60870.cpp +++ b/lib/nodes/iec60870.cpp @@ -576,7 +576,7 @@ bool SlaveNode::onInterrogation(IMasterConnection connection, CS101_ASDU asdu, bool SlaveNode::onASDU(IMasterConnection connection, CS101_ASDU asdu) const noexcept { - logger->warn("Ignoring ASDU type {}", CS101_ASDU_getTypeID(asdu)); + logger->warn("Ignoring ASDU type {}", (int)CS101_ASDU_getTypeID(asdu)); return true; } diff --git a/lib/nodes/infiniband.cpp b/lib/nodes/infiniband.cpp index 032d7f864..cfbc352c4 100644 --- a/lib/nodes/infiniband.cpp +++ b/lib/nodes/infiniband.cpp @@ -577,7 +577,7 @@ static void *ib_rdma_cm_event_thread(void *ctx) { break; default: - throw RuntimeError("Unknown event occurred: {}", event->event); + throw RuntimeError("Unknown event occurred: {}", (int)event->event); } rdma_ack_cm_event(event); @@ -836,7 +836,7 @@ int villas::node::ib_read(NodeCompat *n, struct Sample *const smps[], n->logger->debug("Received IBV_WC_WR_FLUSH_ERR (ib_read). Ignore it."); else if (wc[j].status != IBV_WC_SUCCESS) n->logger->warn("Work Completion status was not IBV_WC_SUCCESS: {}", - wc[j].status); + (int)wc[j].status); /* 32 byte of meta data is always transferred. We should substract it. * Furthermore, in case of an unreliable connection, a 40 byte @@ -987,7 +987,7 @@ int villas::node::ib_write(NodeCompat *n, struct Sample *const smps[], for (int i = 0; i < ret; i++) { if (wc[i].status != IBV_WC_SUCCESS && wc[i].status != IBV_WC_WR_FLUSH_ERR) n->logger->warn("Work Completion status was not IBV_WC_SUCCESS: {}", - wc[i].status); + (int)wc[i].status); // TODO: fix release logic // smps[*release] = (struct Sample *) (wc[i].wr_id); diff --git a/lib/nodes/webrtc/peer_connection.cpp b/lib/nodes/webrtc/peer_connection.cpp index e32e58eef..3a5f3d383 100644 --- a/lib/nodes/webrtc/peer_connection.cpp +++ b/lib/nodes/webrtc/peer_connection.cpp @@ -24,22 +24,6 @@ using namespace villas; using namespace villas::node; using namespace villas::node::webrtc; -/* - * libdatachannel defines the operator<< overloads required to format - * rtc::PeerConnection::State and similar in the global namespace. - * But C++ ADL based overload set construction does not find these operators, - * if these are invoked in the spdlog/fmt libraries. - * - * See this issue for a short explaination of ADL errors: - * https://github.com/gabime/spdlog/issues/1227#issuecomment-532009129 - * - * Adding the global ::operator<< overload set to the namespace rtc where - * the data structures are defined, allows ADL to pick these up in spdlog/fmt. - */ -namespace rtc { -using ::operator<<; -} - PeerConnection::PeerConnection(const std::string &server, const std::string &session, const std::string &peer, diff --git a/lib/nodes/websocket.cpp b/lib/nodes/websocket.cpp index 3520cd8e9..4fa92b851 100644 --- a/lib/nodes/websocket.cpp +++ b/lib/nodes/websocket.cpp @@ -124,7 +124,7 @@ static void websocket_connection_close(struct websocket_connection *c, c->node->logger->debug( "Closing WebSocket connection with {}: status={}, reason={}", - c->toString(), status, reason); + c->toString(), (int)status, reason); c->state = websocket_connection::State::CLOSED; }