From 4f2a0626f72f64f2a65020f534c9c7f6a591618b Mon Sep 17 00:00:00 2001 From: Adrian DC Date: Thu, 23 Apr 2020 22:06:14 +0200 Subject: [PATCH] feat: implement #45: add support for logging configuration --- API.md | 13 +++++++++++++ src/internal/sio_client_impl.cpp | 16 ++++++++++++++++ src/internal/sio_client_impl.h | 8 +++++++- src/sio_client.cpp | 17 ++++++++++++++++- src/sio_client.h | 8 +++++++- 5 files changed, 59 insertions(+), 3 deletions(-) diff --git a/API.md b/API.md index 1061fc74..f1280eb4 100644 --- a/API.md +++ b/API.md @@ -168,6 +168,19 @@ Set listener for reconnecting is in process. Set listener for reconnecting event, called once a delayed connecting is scheduled. +#### Logs +`void set_logs_default()` + +Configure logs to the default level (connect, disconnect, app) + +`void set_logs_quiet()` + +Configure logs to the quiet level + +`void set_logs_verbose()` + +Configure logs to the verbose level + #### Namespace `socket::ptr socket(std::string const& nsp)` diff --git a/src/internal/sio_client_impl.cpp b/src/internal/sio_client_impl.cpp index e8da085e..70d51349 100644 --- a/src/internal/sio_client_impl.cpp +++ b/src/internal/sio_client_impl.cpp @@ -157,6 +157,22 @@ namespace sio } } + void client_impl::set_logs_default() + { + m_client.clear_access_channels(websocketpp::log::alevel::all); + m_client.set_access_channels(websocketpp::log::alevel::connect | websocketpp::log::alevel::disconnect | websocketpp::log::alevel::app); + } + + void client_impl::set_logs_quiet() + { + m_client.clear_access_channels(websocketpp::log::alevel::all); + } + + void client_impl::set_logs_verbose() + { + m_client.set_access_channels(websocketpp::log::alevel::all); + } + /*************************protected:*************************/ void client_impl::send(packet& p) { diff --git a/src/internal/sio_client_impl.h b/src/internal/sio_client_impl.h index 311a267e..6af9b941 100644 --- a/src/internal/sio_client_impl.h +++ b/src/internal/sio_client_impl.h @@ -116,7 +116,13 @@ namespace sio void set_reconnect_delay(unsigned millis) {m_reconn_delay = millis;if(m_reconn_delay_maxmillis) m_reconn_delay = millis;} - + + void set_logs_default(); + + void set_logs_quiet(); + + void set_logs_verbose(); + protected: void send(packet& p); diff --git a/src/sio_client.cpp b/src/sio_client.cpp index 48d0ce20..bb40cb30 100644 --- a/src/sio_client.cpp +++ b/src/sio_client.cpp @@ -124,5 +124,20 @@ namespace sio { m_impl->set_reconnect_delay_max(millis); } - + + void client::set_logs_default() + { + m_impl->set_logs_default(); + } + + void client::set_logs_quiet() + { + m_impl->set_logs_quiet(); + } + + void client::set_logs_verbose() + { + m_impl->set_logs_verbose(); + } + } diff --git a/src/sio_client.h b/src/sio_client.h index 77be0a2d..c37882ab 100644 --- a/src/sio_client.h +++ b/src/sio_client.h @@ -66,7 +66,13 @@ namespace sio void set_reconnect_delay(unsigned millis); void set_reconnect_delay_max(unsigned millis); - + + void set_logs_default(); + + void set_logs_quiet(); + + void set_logs_verbose(); + sio::socket::ptr const& socket(const std::string& nsp = ""); // Closes the connection