Skip to content

Commit

Permalink
feat: implement #45: add support for logging configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianDC authored and darrachequesne committed Jan 15, 2021
1 parent ec4d540 commit 1b42ce7
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 3 deletions.
13 changes: 13 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)`

Expand Down
16 changes: 16 additions & 0 deletions src/internal/sio_client_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,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)
{
Expand Down
8 changes: 7 additions & 1 deletion src/internal/sio_client_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,13 @@ namespace sio
void set_reconnect_delay(unsigned millis) {m_reconn_delay = millis;if(m_reconn_delay_max<millis) m_reconn_delay_max = millis;}

void set_reconnect_delay_max(unsigned millis) {m_reconn_delay_max = millis;if(m_reconn_delay>millis) m_reconn_delay = millis;}


void set_logs_default();

void set_logs_quiet();

void set_logs_verbose();

protected:
void send(packet& p);

Expand Down
17 changes: 16 additions & 1 deletion src/sio_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,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();
}

}
8 changes: 7 additions & 1 deletion src/sio_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1b42ce7

Please sign in to comment.