Skip to content

Commit

Permalink
Merge pull request #3 from AdrianDC/45
Browse files Browse the repository at this point in the history
feat: implement socketio#45: add support for logging configuration
  • Loading branch information
alexdany657 authored Jun 19, 2020
2 parents 8117e13 + 4f2a062 commit 426d1af
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 @@ -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)
{
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 @@ -116,7 +116,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 @@ -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();
}

}
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 426d1af

Please sign in to comment.