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

@@ -180,8 +180,9 @@ bool isValidated (LedgerMaster& ledgerMaster, ReadView const& ledger,
}
catch (SHAMapMissingNode const&)
{
JLOG (app.journal ("RPCHandler").warning)
<< "Missing SHANode " << std::to_string (seq);
auto stream = app.journal ("RPCHandler").warn();
JLOG (stream)
<< "Missing SHANode " << std::to_string (seq);
return false;
}

View File

@@ -119,7 +119,7 @@ error_code_i fillHandler (Context& context,
int jc = context.app.getJobQueue ().getJobCountGE (jtCLIENT);
if (jc > Tuning::maxJobQueueClients)
{
JLOG (context.j.debug) << "Too busy for command: " << jc;
JLOG (context.j.debug()) << "Too busy for command: " << jc;
return rpcTOO_BUSY;
}
}
@@ -129,8 +129,8 @@ error_code_i fillHandler (Context& context,
std::string strCommand = context.params[jss::command].asString ();
JLOG (context.j.trace) << "COMMAND:" << strCommand;
JLOG (context.j.trace) << "REQUEST:" << context.params;
JLOG (context.j.trace()) << "COMMAND:" << strCommand;
JLOG (context.j.trace()) << "REQUEST:" << context.params;
auto handler = getHandler(strCommand);
@@ -143,7 +143,7 @@ error_code_i fillHandler (Context& context,
if ((handler->condition_ & NEEDS_NETWORK_CONNECTION) &&
(context.netOps.getOperatingMode () < NetworkOPs::omSYNCING))
{
JLOG (context.j.info)
JLOG (context.j.info())
<< "Insufficient network mode for RPC: "
<< context.netOps.strOperatingMode ();
@@ -164,7 +164,7 @@ error_code_i fillHandler (Context& context,
if (cID + 10 < vID)
{
JLOG (context.j.debug) << "Current ledger ID(" << cID <<
JLOG (context.j.debug()) << "Current ledger ID(" << cID <<
") is less than validated ledger ID(" << vID << ")";
return rpcNO_CURRENT;
}
@@ -192,7 +192,7 @@ Status callMethod (
}
catch (std::exception& e)
{
JLOG (context.j.info) << "Caught throw: " << e.what ();
JLOG (context.j.info()) << "Caught throw: " << e.what ();
if (context.loadType == Resource::feeReferenceRPC)
context.loadType = Resource::feeExceptionRPC;
@@ -209,7 +209,7 @@ void getResult (
auto&& result = Json::addObject (object, jss::result);
if (auto status = callMethod (context, method, name, result))
{
JLOG (context.j.debug) << "rpcError: " << status.toString();
JLOG (context.j.debug()) << "rpcError: " << status.toString();
result[jss::status] = jss::error;
result[jss::request] = context.params;
}
@@ -236,13 +236,13 @@ Status doCommand (
if (! context.headers.user.empty() ||
! context.headers.forwardedFor.empty())
{
context.j.debug << "start command: " << handler->name_ <<
JLOG(context.j.debug()) << "start command: " << handler->name_ <<
", X-User: " << context.headers.user << ", X-Forwarded-For: " <<
context.headers.forwardedFor;
auto ret = callMethod (context, method, handler->name_, result);
context.j.debug << "finish command: " << handler->name_ <<
JLOG(context.j.debug()) << "finish command: " << handler->name_ <<
", X-User: " << context.headers.user << ", X-Forwarded-For: " <<
context.headers.forwardedFor;

View File

@@ -218,7 +218,7 @@ static Json::Value checkPayment(
}
auto j = app.journal ("RPCHandler");
JLOG (j.debug)
JLOG (j.debug())
<< "transactionSign: build_path: "
<< result.getJson (0);
@@ -378,7 +378,7 @@ transactionPreProcessImpl (
if (verify && !sle)
{
// If not offline and did not find account, error.
JLOG (j.debug)
JLOG (j.debug())
<< "transactionSign: Failed to find source account "
<< "in current ledger: "
<< toBase58(srcAddressID);
@@ -417,7 +417,7 @@ transactionPreProcessImpl (
{
if (! sle)
{
JLOG (j.debug)
JLOG (j.debug())
<< "transactionSign: Failed to find source account "
<< "in current ledger: "
<< toBase58(srcAddressID);
@@ -441,7 +441,7 @@ transactionPreProcessImpl (
// XXX Ignore transactions for accounts not created.
return rpcError (rpcSRC_ACT_NOT_FOUND);
JLOG (j.trace)
JLOG (j.trace())
<< "verify: " << toBase58(calcAccountID(keypair.first))
<< " : " << toBase58(srcAddressID);
@@ -704,7 +704,7 @@ Json::Value transactionSign (
using namespace detail;
auto j = app.journal ("RPCHandler");
JLOG (j.debug) << "transactionSign: " << jvRequest;
JLOG (j.debug()) << "transactionSign: " << jvRequest;
// Add and amend fields based on the transaction type.
SigningForParams signForParams;
@@ -739,7 +739,7 @@ Json::Value transactionSubmit (
using namespace detail;
auto j = app.journal ("RPCHandler");
JLOG (j.debug) << "transactionSubmit: " << jvRequest;
JLOG (j.debug()) << "transactionSubmit: " << jvRequest;
// Add and amend fields based on the transaction type.
@@ -861,7 +861,7 @@ Json::Value transactionSignFor (
std::shared_ptr<ReadView const> const& ledger)
{
auto j = app.journal ("RPCHandler");
JLOG (j.debug) << "transactionSignFor: " << jvRequest;
JLOG (j.debug()) << "transactionSignFor: " << jvRequest;
// Verify presence of the signer's account field.
const char accountField[] = "account";
@@ -972,7 +972,7 @@ Json::Value transactionSubmitMultiSigned (
ProcessTransactionFn const& processTransaction)
{
auto j = app.journal ("RPCHandler");
JLOG (j.debug)
JLOG (j.debug())
<< "transactionSubmitMultiSigned: " << jvRequest;
// When multi-signing, the "Sequence" and "SigningPubKey" fields must
@@ -1001,7 +1001,7 @@ Json::Value transactionSubmitMultiSigned (
if (!sle)
{
// If did not find account, error.
JLOG (j.debug)
JLOG (j.debug())
<< "transactionSubmitMultiSigned: Failed to find source account "
<< "in current ledger: "
<< toBase58(srcAddressID);