Access Journal::Stream using member functions (RIPD-1087):

Replace Journal public data members with member function accessors
in order to make Journal lighter weight.  The change makes a
Journal cheaper to pass by value.

Also add missing stream checks (e.g., calls to JLOG) to avoid
text processing that ultimately will not be stored in the log.
This commit is contained in:
Scott Schurr
2016-03-09 10:48:21 -08:00
committed by seelabs
parent b3f5986c83
commit 7a4bd2278d
132 changed files with 1843 additions and 1799 deletions

View File

@@ -131,7 +131,7 @@ public:
if (boost::asio::ssl::rfc2818_verification (domain) (preverified, ctx))
return true;
JLOG (j.warning) <<
JLOG (j.warn()) <<
"Outbound SSL connection to " << domain <<
" fails certificate verification";
return false;
@@ -319,7 +319,7 @@ protected:
if (ec)
{
JLOG (j_.warning) <<
JLOG (j_.warn()) <<
"Handle autodetect error: " << ec;
cbFunc (ec);
}
@@ -332,14 +332,14 @@ protected:
|| ((mBuffer[3] < 127) && (mBuffer[3] > 31))))
{
// not ssl
JLOG (j_.trace) << "non-SSL";
JLOG (j_.trace()) << "non-SSL";
mSecure = false;
cbFunc (ec);
}
else
{
// ssl
JLOG (j_.trace) << "SSL";
JLOG (j_.trace()) << "SSL";
mSecure = true;
mSocket->async_handshake (ssl_socket::server, cbFunc);
}

View File

@@ -159,7 +159,7 @@ ConnectionImpl <WebSocket>::ConnectionImpl (
if (! m_forwardedFor.empty() || ! m_user.empty())
{
j_.debug << "connect secure_gateway X-Forwarded-For: " <<
JLOG(j_.debug()) << "connect secure_gateway X-Forwarded-For: " <<
m_forwardedFor << ", X-User: " << m_user;
}
}
@@ -174,7 +174,7 @@ template <class WebSocket>
void ConnectionImpl <WebSocket>::rcvMessage (
message_ptr const& msg, bool& msgRejected, bool& runQueue)
{
JLOG(j_.debug) <<
JLOG(j_.debug()) <<
"WebSocket: received " << msg->get_payload();
ScopedLockType sl (m_receiveQueueMutex);
@@ -337,7 +337,7 @@ void ConnectionImpl <WebSocket>::preDestroy ()
{
if (! m_forwardedFor.empty() || ! m_user.empty())
{
j_.debug << "disconnect secure_gateway X-Forwarded-For: " <<
JLOG(j_.debug()) << "disconnect secure_gateway X-Forwarded-For: " <<
m_forwardedFor << ", X-User: " << m_user;
}
@@ -355,7 +355,7 @@ void ConnectionImpl <WebSocket>::preDestroy ()
template <class WebSocket>
void ConnectionImpl <WebSocket>::send (Json::Value const& jvObj, bool broadcast)
{
JLOG (j_.debug) <<
JLOG (j_.debug()) <<
"WebSocket: sending " << to_string (jvObj);
connection_ptr ptr = m_connection.lock ();
if (ptr)
@@ -365,7 +365,7 @@ void ConnectionImpl <WebSocket>::send (Json::Value const& jvObj, bool broadcast)
template <class WebSocket>
void ConnectionImpl <WebSocket>::disconnect ()
{
JLOG (j_.debug) <<
JLOG (j_.debug()) <<
"WebSocket: disconnecting";
connection_ptr ptr = m_connection.lock ();

View File

@@ -125,7 +125,7 @@ public:
{
try
{
auto& jm = broadcast ? j_.trace : j_.debug;
auto jm = broadcast ? j_.trace() : j_.debug();
JLOG (jm)
<< "Ws:: Sending '" << strMessage << "'";
@@ -162,7 +162,7 @@ public:
cpClient->terminate ({});
try
{
JLOG (j_.debug) <<
JLOG (j_.debug()) <<
"Ws:: ping_out(" <<
// TODO(tom): re-enable this logging.
// cpClient->get_socket ().remote_endpoint ().to_string ()
@@ -213,7 +213,7 @@ public:
assert (result.second);
(void) result.second;
JLOG (j_.debug) <<
JLOG (j_.debug()) <<
"Ws:: on_open(" << remoteEndpoint << ")";
}
catch (std::exception const&)
@@ -235,7 +235,7 @@ public:
}
try
{
JLOG (j_.debug) <<
JLOG (j_.debug()) <<
"Ws:: on_pong(" << cpClient->get_socket ().remote_endpoint() << ")";
}
catch (std::exception const&)
@@ -267,7 +267,7 @@ public:
{
try
{
JLOG (j_.debug) <<
JLOG (j_.debug()) <<
"Ws:: " << reason << "(" <<
cpClient->get_socket ().remote_endpoint() <<
") not found";
@@ -286,7 +286,7 @@ public:
ptr->preDestroy (); // Must be done before we return
try
{
JLOG (j_.debug) <<
JLOG (j_.debug()) <<
"Ws:: " << reason << "(" <<
cpClient->get_socket ().remote_endpoint () << ") found";
}
@@ -331,7 +331,7 @@ public:
{
try
{
JLOG (j_.debug) <<
JLOG (j_.debug()) <<
"Ws:: Rejected(" <<
cpClient->get_socket().remote_endpoint() <<
") '" << mpMessage->get_payload () << "'";
@@ -388,7 +388,7 @@ public:
try
{
JLOG (j_.debug)
JLOG (j_.debug())
<< "Ws:: Receiving("
<< cpClient->get_socket ().remote_endpoint ()
<< ") '" << message << "'";

View File

@@ -61,7 +61,7 @@ private:
{
beast::Thread::setCurrentThreadName ("WebSocket");
JLOG (j_.warning)
JLOG (j_.warn())
<< "Websocket: listening on " << desc_.port;
listen();
@@ -70,17 +70,17 @@ private:
endpoint_.reset();
}
JLOG (j_.warning)
JLOG (j_.warn())
<< "Websocket: finished listening on " << desc_.port;
stopped ();
JLOG (j_.warning)
JLOG (j_.warn())
<< "Websocket: stopped on " << desc_.port;
}
void onStart () override
{
JLOG (j_.warning)
JLOG (j_.warn())
<< "Websocket: creating endpoint " << desc_.port;
{
@@ -103,7 +103,7 @@ private:
void onStop () override
{
JLOG (j_.warning)
JLOG (j_.warn())
<< "Websocket: onStop " << desc_.port;
auto endpoint = [&]

View File

@@ -112,12 +112,12 @@ void Server <WebSocket02>::listen()
}
catch (std::exception const& e)
{
JLOG (j_.warning) << "websocketpp exception: "
JLOG (j_.warn()) << "websocketpp exception: "
<< e.what ();
static const int maxRetries = 10;
if (maxRetries && i >= maxRetries)
{
JLOG (j_.warning)
JLOG (j_.warn())
<< "websocketpp exceeded max retries: " << i;
break;
}