diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c2fad3f..a3566c10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,10 @@ target_include_directories(sioclient PRIVATE ${Boost_INCLUDE_DIRS} ${CMAKE_CURRENT_LIST_DIR}/lib/rapidjson/include ) +if(SIO_CLIENT_DEBUG) + target_compile_definitions(sioclient PRIVATE -DSIO_CLIENT_DEBUG) +endif() + set_property(TARGET sioclient PROPERTY CXX_STANDARD 11) set_property(TARGET sioclient PROPERTY CXX_STANDARD_REQUIRED ON) target_link_libraries(sioclient PRIVATE ${Boost_LIBRARIES}) @@ -56,6 +60,10 @@ target_include_directories(sioclient_tls PRIVATE ${Boost_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} ) +if(SIO_CLIENT_DEBUG) + target_compile_definitions(sioclient_tls PRIVATE -DSIO_CLIENT_DEBUG) +endif() + set_property(TARGET sioclient_tls PROPERTY CXX_STANDARD 11) set_property(TARGET sioclient_tls PROPERTY CXX_STANDARD_REQUIRED ON) target_link_libraries(sioclient_tls PRIVATE ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ) diff --git a/src/internal/sio_client_impl.cpp b/src/internal/sio_client_impl.cpp index 618dd1f4..7d608e56 100644 --- a/src/internal/sio_client_impl.cpp +++ b/src/internal/sio_client_impl.cpp @@ -12,10 +12,10 @@ #include #include // Comment this out to disable handshake logging to stdout -#if DEBUG || _DEBUG -#define LOG(x) std::cout << x +#if SIO_CLIENT_DEBUG +# define LOG(x) std::cout << x #else -#define LOG(x) +# define LOG(x) #endif using boost::posix_time::milliseconds; @@ -35,8 +35,8 @@ namespace sio m_reconn_delay_max(25000) { using websocketpp::log::alevel; -#ifndef DEBUG m_client.clear_access_channels(alevel::all); +#ifdef SIO_CLIENT_DEBUG m_client.set_access_channels(alevel::connect|alevel::disconnect|alevel::app); #endif // Initialize the Asio transport policy @@ -251,7 +251,7 @@ namespace sio } if (m_con.expired()) { - cerr << "Error: No active session" << endl; + LOG("Error: No active session" << endl); } else { @@ -275,7 +275,7 @@ namespace sio m_client.send(m_con,*payload_ptr,opcode,ec); if(ec) { - cerr<<"Send failed,reason:"<< ec.message()< -#if _DEBUG || DEBUG -#if SIO_TLS -#include -typedef websocketpp::config::debug_asio_tls client_config; +#ifdef SIO_CLIENT_DEBUG +# if SIO_TLS +# include + typedef websocketpp::config::debug_asio_tls client_config; +# else +# include + typedef websocketpp::config::debug_asio client_config; +# endif //SIO_TLS #else -#include -typedef websocketpp::config::debug_asio client_config; -#endif //SIO_TLS -#else -#if SIO_TLS -#include -typedef websocketpp::config::asio_tls_client client_config; -#else -#include -typedef websocketpp::config::asio_client client_config; -#endif //SIO_TLS -#endif //DEBUG +# if SIO_TLS +# include + typedef websocketpp::config::asio_tls_client client_config_base; +# else +# include + typedef websocketpp::config::asio_client client_config_base; +# endif //SIO_TLS + struct client_config : public client_config_base { + static const websocketpp::log::level elog_level + = websocketpp::log::elevel::none; + static const websocketpp::log::level alog_level + = websocketpp::log::alevel::none; + }; +#endif //SIO_CLIENT_DEBUG #include #include diff --git a/src/sio_socket.cpp b/src/sio_socket.cpp index b48134e9..1b0c45aa 100644 --- a/src/sio_socket.cpp +++ b/src/sio_socket.cpp @@ -6,10 +6,10 @@ #include #include -#if DEBUG || _DEBUG -#define LOG(x) std::cout << x +#if SIO_CLIENT_DEBUG +# define LOG(x) std::cout << x #else -#define LOG(x) +# define LOG(x) #endif #define NULL_GUARD(_x_) \