From 0b91d55269c9e6c9e3eda20cbd193977e50b84f5 Mon Sep 17 00:00:00 2001 From: gabime Date: Tue, 25 Feb 2020 15:09:03 +0200 Subject: [PATCH] Refactored tcp_client_sink --- include/spdlog/details/tcp_client.h | 4 ++++ include/spdlog/sinks/tcp_sink.h | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/spdlog/details/tcp_client.h b/include/spdlog/details/tcp_client.h index 29f34839..5b2f0af1 100644 --- a/include/spdlog/details/tcp_client.h +++ b/include/spdlog/details/tcp_client.h @@ -3,6 +3,10 @@ #pragma once +#ifdef _WIN32 +#error tcp_client not supported under windows yet +#endif + // tcp client helper #include #include diff --git a/include/spdlog/sinks/tcp_sink.h b/include/spdlog/sinks/tcp_sink.h index 30e34d95..662c0d96 100644 --- a/include/spdlog/sinks/tcp_sink.h +++ b/include/spdlog/sinks/tcp_sink.h @@ -14,9 +14,10 @@ #pragma once -// tcp client sink -// connect to remote address and send the formatted log. -// will attempt to reconnect if connection drops. +// Simple tcp client sink +// Connects to remote address and send the formatted log. +// Will attempt to reconnect if connection drops. +// If more complicated behaviour is needed (i.e get responses), you can inherit it and override the sink_it_ method. namespace spdlog { namespace sinks { @@ -39,7 +40,7 @@ class tcp_sink : public spdlog::sinks::base_sink public: // connect to tcp host/port or throw if failed // host can be hostname or ip address - tcp_sink(tcp_sink_config sink_config) + explicit tcp_sink(tcp_sink_config sink_config) : config_{std::move(sink_config)} { if (!config_.lazy_connect) @@ -48,7 +49,7 @@ public: } } - ~tcp_sink() override {} + ~tcp_sink() override = default; protected: void sink_it_(const spdlog::details::log_msg &msg) override