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

@@ -120,7 +120,7 @@ bool getSingleSection (IniFileSections& secSource,
}
else if (pmtEntries)
{
JLOG (j.warning) << boost::str (
JLOG (j.warn()) << boost::str (
boost::format ("Section [%s]: requires 1 line not %d lines.") %
strSection % pmtEntries->size ());
}
@@ -442,7 +442,7 @@ void Config::loadFromString (std::string const& fileContents)
if (validatorsFile.empty ())
{
JLOG (j_.error) <<
JLOG (j_.error()) <<
"[" SECTION_VALIDATORS_FILE "]" <<
": " << strTemp <<
" is not a valid path";
@@ -450,7 +450,7 @@ void Config::loadFromString (std::string const& fileContents)
}
else if (!boost::filesystem::exists (validatorsFile))
{
JLOG (j_.error) <<
JLOG (j_.error()) <<
"[" SECTION_VALIDATORS_FILE "]" <<
": the file " << validatorsFile <<
" does not exist";
@@ -458,7 +458,7 @@ void Config::loadFromString (std::string const& fileContents)
}
else if (!boost::filesystem::is_regular_file (validatorsFile))
{
JLOG (j_.error) <<
JLOG (j_.error()) <<
"[" SECTION_VALIDATORS_FILE "]" <<
": the file " << validatorsFile <<
" is not a regular file";
@@ -498,7 +498,7 @@ void Config::loadFromString (std::string const& fileContents)
if (!entries)
{
JLOG (j_.error) <<
JLOG (j_.error()) <<
"[" SECTION_VALIDATORS_FILE "]" <<
": the file " << validatorsFile <<
" does not contain a [" SECTION_VALIDATORS <<

View File

@@ -166,7 +166,7 @@ JobQueue::getJobCountGE (JobType t) const
void
JobQueue::shutdown ()
{
JLOG(m_journal.info) << "Job queue shutting down";
JLOG(m_journal.info()) << "Job queue shutting down";
m_workers.pauseAllThreadsAndWait ();
}
@@ -183,7 +183,7 @@ JobQueue::setThreadCount (int c, bool const standaloneMode)
c = static_cast<int>(std::thread::hardware_concurrency());
c = 2 + std::min (c, 4); // I/O will bottleneck
JLOG(m_journal.info) << "Auto-tuning to " << c <<
JLOG(m_journal.info()) << "Auto-tuning to " << c <<
" validation/transaction/proposal threads";
}
@@ -463,7 +463,7 @@ JobQueue::processTask ()
type = job.getType();
JobTypeData& data(getJobTypeData(type));
beast::Thread::setCurrentThreadName (data.name ());
JLOG(m_journal.trace) << "Doing " << data.name () << " job";
JLOG(m_journal.trace()) << "Doing " << data.name () << " job";
on_dequeue (job.getType (), start_time - job.queue_time ());
job.doJob ();
}

View File

@@ -19,6 +19,7 @@
#include <BeastConfig.h>
#include <ripple/basics/contract.h>
#include <ripple/basics/Log.h>
#include <ripple/basics/mulDiv.h>
#include <ripple/core/LoadFeeTrack.h>
#include <ripple/core/Config.h>
@@ -147,7 +148,7 @@ LoadFeeTrack::raiseLocalFee ()
if (origFee == mLocalTxnLoadFee)
return false;
m_journal.debug << "Local load fee raised from " <<
JLOG(m_journal.debug()) << "Local load fee raised from " <<
origFee << " to " << mLocalTxnLoadFee;
return true;
}
@@ -168,7 +169,7 @@ LoadFeeTrack::lowerLocalFee ()
if (origFee == mLocalTxnLoadFee)
return false;
m_journal.debug << "Local load fee lowered from " <<
JLOG(m_journal.debug()) << "Local load fee lowered from " <<
origFee << " to " << mLocalTxnLoadFee;
return true;
}

View File

@@ -147,7 +147,7 @@ void LoadMonitor::addLoadSample (LoadEvent const& sample)
if (latency.inSeconds() > 0.5)
{
auto& mj = latency.inSeconds() > 1.0 ? j_.warning : j_.info;
auto mj = latency.inSeconds() > 1.0 ? j_.warn() : j_.info();
JLOG (mj)
<< "Job: " << name << " ExecutionTime: " << printElapsed (sample.getSecondsRunning()) <<
" WaitingTime: " << printElapsed (sample.getSecondsWaiting());

View File

@@ -141,7 +141,7 @@ public:
if (it == servers.end ())
{
JLOG(j_.info) <<
JLOG(j_.info()) <<
"SNTP: no server specified";
return;
}
@@ -207,7 +207,7 @@ public:
return;
if (ec)
{
JLOG(j_.error) <<
JLOG(j_.error()) <<
"SNTPClock::onTimer: " << ec.message();
return;
}
@@ -235,18 +235,18 @@ public:
if (! ec)
{
JLOG(j_.trace) <<
JLOG(j_.trace()) <<
"SNTP: Packet from " << ep_;
std::lock_guard<std::mutex> lock (mutex_);
auto const query = queries_.find (ep_);
if (query == queries_.end ())
{
JLOG(j_.debug) <<
JLOG(j_.debug()) <<
"SNTP: Reply from " << ep_ << " found without matching query";
}
else if (query->second.replied)
{
JLOG(j_.debug) <<
JLOG(j_.debug()) <<
"SNTP: Duplicate response from " << ep_;
}
else
@@ -255,12 +255,12 @@ public:
if (time (nullptr) > (query->second.sent + 1))
{
JLOG(j_.warning) <<
JLOG(j_.warn()) <<
"SNTP: Late response from " << ep_;
}
else if (bytes_xferd < 48)
{
JLOG(j_.warning) <<
JLOG(j_.warn()) <<
"SNTP: Short reply from " << ep_ <<
" (" << bytes_xferd << ") " << buf_.size ();
}
@@ -268,7 +268,7 @@ public:
&buf_[0])[NTP_OFF_ORGTS_FRAC] !=
query->second.nonce)
{
JLOG(j_.warning) <<
JLOG(j_.warn()) <<
"SNTP: Reply from " << ep_ << "had wrong nonce";
}
else
@@ -311,7 +311,7 @@ public:
if (best == servers_.end ())
{
JLOG(j_.trace) <<
JLOG(j_.trace()) <<
"SNTP: No server to query";
return false;
}
@@ -320,7 +320,7 @@ public:
if ((best->second != time_t(-1)) && ((best->second + NTP_MIN_QUERY) >= now))
{
JLOG(j_.trace) <<
JLOG(j_.trace()) <<
"SNTP: All servers recently queried";
return false;
}
@@ -333,7 +333,7 @@ public:
&SNTPClientImp::resolveComplete, this,
beast::asio::placeholders::error,
beast::asio::placeholders::iterator));
JLOG(j_.trace) <<
JLOG(j_.trace()) <<
"SNTPClock: Resolve pending for " << best->first;
return true;
}
@@ -346,7 +346,7 @@ public:
return;
if (ec)
{
JLOG(j_.trace) <<
JLOG(j_.trace()) <<
"SNTPClock::resolveComplete: " << ec.message();
return;
}
@@ -371,7 +371,7 @@ public:
if ((query.sent == now) || ((query.sent + 1) == now))
{
// This can happen if the same IP address is reached through multiple names
JLOG(j_.trace) <<
JLOG(j_.trace()) <<
"SNTP: Redundant query suppressed";
return;
}
@@ -395,7 +395,7 @@ public:
if (ec)
{
JLOG(j_.warning) <<
JLOG(j_.warn()) <<
"SNTPClock::onSend: " << ec.message();
return;
}
@@ -412,14 +412,14 @@ public:
if ((info >> 30) == 3)
{
JLOG(j_.info) <<
JLOG(j_.info()) <<
"SNTP: Alarm condition " << ep_;
return;
}
if ((stratum == 0) || (stratum > 14))
{
JLOG(j_.info) <<
JLOG(j_.info()) <<
"SNTP: Unreasonable stratum (" << stratum << ") from " << ep_;
return;
}
@@ -453,7 +453,7 @@ public:
if (timev || offset_)
{
JLOG(j_.trace) << "SNTP: Offset is " << timev <<
JLOG(j_.trace()) << "SNTP: Offset is " << timev <<
", new system offset is " << offset_;
}
}

View File

@@ -238,13 +238,13 @@ private:
auto fname = sqlite3_db_filename (&conn_, "main");
if (ret != SQLITE_OK)
{
auto& jm = (ret == SQLITE_LOCKED) ? j_.trace : j_.warning;
auto jm = (ret == SQLITE_LOCKED) ? j_.trace() : j_.warn();
JLOG (jm)
<< "WAL(" << fname << "): error " << ret;
}
else
{
JLOG (j_.trace)
JLOG (j_.trace())
<< "WAL(" << fname << "): frames="
<< log << ", written=" << ckpt;
}

View File

@@ -94,13 +94,13 @@ public:
{
if (std::abs (closeOffset_.count()) < 60)
{
JLOG(j_.info) <<
JLOG(j_.info()) <<
"TimeKeeper: Close time offset now " <<
closeOffset_.count();
}
else
{
JLOG(j_.warning) <<
JLOG(j_.warn()) <<
"TimeKeeper: Large close time offset = " <<
closeOffset_.count();
}