From f35918ce6e5009abeb702ffd724a69e982b36fb5 Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Sat, 8 Jun 2013 18:31:21 -0500 Subject: [PATCH] split log_fail_result from log_close_result --- websocketpp/connection.hpp | 7 ++++++- websocketpp/impl/connection_impl.hpp | 11 +++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/websocketpp/connection.hpp b/websocketpp/connection.hpp index 1536a644bc..b2c6ee0677 100644 --- a/websocketpp/connection.hpp +++ b/websocketpp/connection.hpp @@ -1040,11 +1040,16 @@ private: /// Prints information about a connection being closed to the access log /** - * Prints information about a connection being closed to the access log. * Includes: local and remote close codes and reasons */ void log_close_result(); + /// Prints information about a connection being failed to the access log + /** + * Includes: error code and message for why it was failed + */ + void log_fail_result(); + // static settings const std::string m_user_agent; diff --git a/websocketpp/impl/connection_impl.hpp b/websocketpp/impl/connection_impl.hpp index 0f44413cf0..bbdb9e8252 100644 --- a/websocketpp/impl/connection_impl.hpp +++ b/websocketpp/impl/connection_impl.hpp @@ -1409,8 +1409,7 @@ void connection::handle_terminate(terminate_status tstat, if (m_fail_handler) { m_fail_handler(m_connection_hdl); } - // TODO: custom fail output log format? - log_close_result(); + log_fail_result(); } else if (tstat == closed) { if (m_close_handler) { m_close_handler(m_connection_hdl); @@ -1912,6 +1911,14 @@ void connection::log_close_result() m_alog.write(log::alevel::disconnect,s.str()); } +template +void connection::log_fail_result() +{ + // TODO: include more information about the connection? + // should this be filed under connect rather than disconnect? + m_alog.write(log::alevel::disconnect,"Failed: "+m_ec.message()); +} + } // namespace websocketpp #endif // WEBSOCKETPP_CONNECTION_IMPL_HPP