mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 11:35:53 +00:00
Inject journals:
Calls to WriteLog are replaced with injected journals
This commit is contained in:
@@ -34,7 +34,7 @@ class RPCSubImp
|
||||
public:
|
||||
RPCSubImp (InfoSub::Source& source, boost::asio::io_service& io_service,
|
||||
JobQueue& jobQueue, std::string const& strUrl, std::string const& strUsername,
|
||||
std::string const& strPassword)
|
||||
std::string const& strPassword, Logs& logs)
|
||||
: RPCSub (source)
|
||||
, m_io_service (io_service)
|
||||
, m_jobQueue (jobQueue)
|
||||
@@ -43,6 +43,8 @@ public:
|
||||
, mUsername (strUsername)
|
||||
, mPassword (strPassword)
|
||||
, mSending (false)
|
||||
, j_ (logs.journal ("RPCSub"))
|
||||
, logs_ (logs)
|
||||
{
|
||||
std::string strScheme;
|
||||
|
||||
@@ -64,7 +66,7 @@ public:
|
||||
if (mPort < 0)
|
||||
mPort = mSSL ? 443 : 80;
|
||||
|
||||
WriteLog (lsINFO, RPCSub) <<
|
||||
JLOG (j_.info) <<
|
||||
"RPCCall::fromNetwork sub: ip=" << mIp <<
|
||||
" port=" << mPort <<
|
||||
" ssl= "<< (mSSL ? "yes" : "no") <<
|
||||
@@ -82,11 +84,12 @@ public:
|
||||
if (mDeque.size () >= eventQueueMax)
|
||||
{
|
||||
// Drop the previous event.
|
||||
WriteLog (lsWARNING, RPCSub) << "RPCCall::fromNetwork drop";
|
||||
JLOG (j_.warning) << "RPCCall::fromNetwork drop";
|
||||
mDeque.pop_back ();
|
||||
}
|
||||
|
||||
WriteLog (broadcast ? lsDEBUG : lsINFO, RPCSub) <<
|
||||
auto& jm = broadcast ? j_.debug : j_.info;
|
||||
JLOG (jm) <<
|
||||
"RPCCall::fromNetwork push: " << jvObj;
|
||||
|
||||
mDeque.push_back (std::make_pair (mSeq++, jvObj));
|
||||
@@ -96,7 +99,7 @@ public:
|
||||
// Start a sending thread.
|
||||
mSending = true;
|
||||
|
||||
WriteLog (lsINFO, RPCSub) << "RPCCall::fromNetwork start";
|
||||
JLOG (j_.info) << "RPCCall::fromNetwork start";
|
||||
|
||||
m_jobQueue.addJob (
|
||||
jtCLIENT, "RPCSub::sendThread", [this] (Job&) {
|
||||
@@ -156,7 +159,7 @@ private:
|
||||
// XXX Might not need this in a try.
|
||||
try
|
||||
{
|
||||
WriteLog (lsINFO, RPCSub) << "RPCCall::fromNetwork: " << mIp;
|
||||
JLOG (j_.info) << "RPCCall::fromNetwork: " << mIp;
|
||||
|
||||
RPCCall::fromNetwork (
|
||||
m_io_service,
|
||||
@@ -165,11 +168,12 @@ private:
|
||||
mPath, "event",
|
||||
jvEvent,
|
||||
mSSL,
|
||||
true);
|
||||
true,
|
||||
logs_);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
WriteLog (lsINFO, RPCSub) << "RPCCall::fromNetwork exception: " << e.what ();
|
||||
JLOG (j_.info) << "RPCCall::fromNetwork exception: " << e.what ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,6 +202,9 @@ private:
|
||||
bool mSending; // Sending threead is active.
|
||||
|
||||
std::deque<std::pair<int, Json::Value> > mDeque;
|
||||
|
||||
beast::Journal j_;
|
||||
Logs& logs_;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -210,11 +217,12 @@ RPCSub::RPCSub (InfoSub::Source& source)
|
||||
std::shared_ptr<RPCSub> make_RPCSub (
|
||||
InfoSub::Source& source, boost::asio::io_service& io_service,
|
||||
JobQueue& jobQueue, std::string const& strUrl,
|
||||
std::string const& strUsername, std::string const& strPassword)
|
||||
std::string const& strUsername, std::string const& strPassword,
|
||||
Logs& logs)
|
||||
{
|
||||
return std::make_shared<RPCSubImp> (std::ref (source),
|
||||
std::ref (io_service), std::ref (jobQueue),
|
||||
strUrl, strUsername, strPassword);
|
||||
strUrl, strUsername, strPassword, logs);
|
||||
}
|
||||
|
||||
} // ripple
|
||||
|
||||
Reference in New Issue
Block a user