mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 14:05:51 +00:00
Implement a debug Journal
This commit is contained in:
@@ -790,12 +790,10 @@ bool Ledger::walkLedger (beast::Journal j) const
|
|||||||
stateMap_->walkMap (missingNodes1, 32);
|
stateMap_->walkMap (missingNodes1, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ShouldLog (lsINFO, Ledger) && !missingNodes1.empty ())
|
if (j.info && !missingNodes1.empty ())
|
||||||
{
|
{
|
||||||
JLOG (j.info)
|
j.info << missingNodes1.size () << " missing account node(s)";
|
||||||
<< missingNodes1.size () << " missing account node(s)";
|
j.info << "First: " << missingNodes1[0];
|
||||||
JLOG (j.info)
|
|
||||||
<< "First: " << missingNodes1[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (txMap_->getHash().isZero() &&
|
if (txMap_->getHash().isZero() &&
|
||||||
@@ -809,12 +807,10 @@ bool Ledger::walkLedger (beast::Journal j) const
|
|||||||
txMap_->walkMap (missingNodes2, 32);
|
txMap_->walkMap (missingNodes2, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ShouldLog (lsINFO, Ledger) && !missingNodes2.empty ())
|
if (j.info && !missingNodes2.empty ())
|
||||||
{
|
{
|
||||||
JLOG (j.info)
|
j.info << missingNodes2.size () << " missing transaction node(s)";
|
||||||
<< missingNodes2.size () << " missing transaction node(s)";
|
j.info << "First: " << missingNodes2[0];
|
||||||
JLOG (j.info)
|
|
||||||
<< "First: " << missingNodes2[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return missingNodes1.empty () && missingNodes2.empty ();
|
return missingNodes1.empty () && missingNodes2.empty ();
|
||||||
@@ -1057,16 +1053,15 @@ static bool saveValidatedLedger (
|
|||||||
sql += ")";
|
sql += ")";
|
||||||
}
|
}
|
||||||
sql += ";";
|
sql += ";";
|
||||||
if (ShouldLog (lsTRACE, Ledger))
|
JLOG (j.trace) << "ActTx: " << sql;
|
||||||
{
|
|
||||||
JLOG (j.trace) << "ActTx: " << sql;
|
|
||||||
}
|
|
||||||
*db << sql;
|
*db << sql;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
JLOG (j.warning)
|
JLOG (j.warning)
|
||||||
<< "Transaction in ledger " << seq
|
<< "Transaction in ledger " << seq
|
||||||
<< " affects no accounts";
|
<< " affects no accounts";
|
||||||
|
}
|
||||||
|
|
||||||
*db <<
|
*db <<
|
||||||
(STTx::getMetaSQLInsertReplaceHeader () +
|
(STTx::getMetaSQLInsertReplaceHeader () +
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ void OrderBookDB::update(
|
|||||||
}
|
}
|
||||||
catch (const SHAMapMissingNode&)
|
catch (const SHAMapMissingNode&)
|
||||||
{
|
{
|
||||||
JLOG (j_.info)
|
JLOG (j_.info)
|
||||||
<< "OrderBookDB::update encountered a missing node";
|
<< "OrderBookDB::update encountered a missing node";
|
||||||
std::lock_guard <std::recursive_mutex> sl (mLock);
|
std::lock_guard <std::recursive_mutex> sl (mLock);
|
||||||
mSeq = 0;
|
mSeq = 0;
|
||||||
|
|||||||
@@ -367,15 +367,17 @@ void LedgerConsensusImp::mapCompleteInternal (
|
|||||||
std::shared_ptr<SHAMap> const& map,
|
std::shared_ptr<SHAMap> const& map,
|
||||||
bool acquired)
|
bool acquired)
|
||||||
{
|
{
|
||||||
CondLog (acquired, lsDEBUG, LedgerConsensus)
|
if (acquired)
|
||||||
<< "We have acquired TXS " << hash;
|
{
|
||||||
|
JLOG (j_.trace) << "We have acquired txs " << hash;
|
||||||
|
}
|
||||||
|
|
||||||
if (!map) // If the map was invalid
|
if (!map) // If the map was invalid
|
||||||
{
|
{
|
||||||
// this is an invalid/corrupt map
|
|
||||||
mAcquired[hash] = map;
|
|
||||||
JLOG (j_.warning)
|
JLOG (j_.warning)
|
||||||
<< "A trusted node directed us to acquire an invalid TXN map";
|
<< "Tried to acquire invalid transaction map: "
|
||||||
|
<< hash;
|
||||||
|
mAcquired[hash] = map;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,9 +389,7 @@ void LedgerConsensusImp::mapCompleteInternal (
|
|||||||
if (it != mAcquired.end ())
|
if (it != mAcquired.end ())
|
||||||
{
|
{
|
||||||
if (it->second)
|
if (it->second)
|
||||||
{
|
|
||||||
return; // we already have this map
|
return; // we already have this map
|
||||||
}
|
|
||||||
|
|
||||||
// We previously failed to acquire this map, now we have it
|
// We previously failed to acquire this map, now we have it
|
||||||
mAcquired.erase (hash);
|
mAcquired.erase (hash);
|
||||||
@@ -422,14 +422,20 @@ void LedgerConsensusImp::mapCompleteInternal (
|
|||||||
createDisputes (it2->second, map);
|
createDisputes (it2->second, map);
|
||||||
}
|
}
|
||||||
else if (!mOurPosition)
|
else if (!mOurPosition)
|
||||||
|
{
|
||||||
JLOG (j_.debug)
|
JLOG (j_.debug)
|
||||||
<< "Not creating disputes: no position yet.";
|
<< "Not creating disputes: no position yet.";
|
||||||
|
}
|
||||||
else if (mOurPosition->isBowOut ())
|
else if (mOurPosition->isBowOut ())
|
||||||
|
{
|
||||||
JLOG (j_.warning)
|
JLOG (j_.warning)
|
||||||
<< "Not creating disputes: not participating.";
|
<< "Not creating disputes: not participating.";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
JLOG (j_.debug)
|
JLOG (j_.debug)
|
||||||
<< "Not creating disputes: identical position.";
|
<< "Not creating disputes: identical position.";
|
||||||
|
}
|
||||||
|
|
||||||
mAcquired[hash] = map;
|
mAcquired[hash] = map;
|
||||||
|
|
||||||
@@ -446,11 +452,11 @@ void LedgerConsensusImp::mapCompleteInternal (
|
|||||||
{
|
{
|
||||||
adjustCount (map, peers);
|
adjustCount (map, peers);
|
||||||
}
|
}
|
||||||
else
|
else if (acquired)
|
||||||
{
|
{
|
||||||
CondLog (acquired, lsWARNING, LedgerConsensus)
|
JLOG (j_.warning)
|
||||||
<< "By the time we got the map "
|
<< "By the time we got the map " << hash
|
||||||
<< hash << " no peers were proposing it";
|
<< " no peers were proposing it";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1623,10 +1629,14 @@ void LedgerConsensusImp::updateOurPositions ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CondLog (!mHaveCloseTimeConsensus, lsDEBUG, LedgerConsensus)
|
if (!mHaveCloseTimeConsensus)
|
||||||
<< "No CT consensus: Proposers:" << mPeerPositions.size ()
|
{
|
||||||
<< " Proposing:" << (mProposing ? "yes" : "no") << " Thresh:"
|
JLOG (j_.debug) << "No CT consensus:"
|
||||||
<< threshConsensus << " Pos:" << closeTime.time_since_epoch().count();
|
<< " Proposers:" << mPeerPositions.size ()
|
||||||
|
<< " Proposing:" << (mProposing ? "yes" : "no")
|
||||||
|
<< " Thresh:" << threshConsensus
|
||||||
|
<< " Pos:" << closeTime.time_since_epoch().count();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporarily send a new proposal if there's any change to our
|
// Temporarily send a new proposal if there's any change to our
|
||||||
|
|||||||
@@ -596,9 +596,14 @@ LedgerMaster::fixMismatch (Ledger::ref ledger)
|
|||||||
if (otherLedger && (otherLedger->getHash () == *hash))
|
if (otherLedger && (otherLedger->getHash () == *hash))
|
||||||
{
|
{
|
||||||
// we closed the seam
|
// we closed the seam
|
||||||
CondLog (invalidate != 0, lsWARNING, LedgerMaster) <<
|
if (invalidate != 0)
|
||||||
"Match at " << lSeq << ", " << invalidate <<
|
{
|
||||||
" prior ledgers invalidated";
|
JLOG (m_journal.warning)
|
||||||
|
<< "Match at " << lSeq
|
||||||
|
<< ", " << invalidate
|
||||||
|
<< " prior ledgers invalidated";
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -609,8 +614,11 @@ LedgerMaster::fixMismatch (Ledger::ref ledger)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// all prior ledgers invalidated
|
// all prior ledgers invalidated
|
||||||
CondLog (invalidate != 0, lsWARNING, LedgerMaster) << "All " <<
|
if (invalidate != 0)
|
||||||
invalidate << " prior ledgers invalidated";
|
{
|
||||||
|
JLOG (m_journal.warning) <<
|
||||||
|
"All " << invalidate << " prior ledgers invalidated";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -100,6 +100,22 @@ private:
|
|||||||
std::uint32_t maxSeq = 0;
|
std::uint32_t maxSeq = 0;
|
||||||
std::mutex maxSeqLock;
|
std::mutex maxSeqLock;
|
||||||
|
|
||||||
|
void acquire (
|
||||||
|
uint256 const& hash,
|
||||||
|
std::uint32_t seq)
|
||||||
|
{
|
||||||
|
if (hash.isNonZero())
|
||||||
|
{
|
||||||
|
auto j = app_.journal ("Ledger");
|
||||||
|
|
||||||
|
JLOG (j.error) <<
|
||||||
|
"Missing node in " << to_string (hash);
|
||||||
|
|
||||||
|
app_.getInboundLedgers ().acquire (
|
||||||
|
hash, seq, InboundLedger::fcGENERIC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AppFamily (AppFamily const&) = delete;
|
AppFamily (AppFamily const&) = delete;
|
||||||
AppFamily& operator= (AppFamily const&) = delete;
|
AppFamily& operator= (AppFamily const&) = delete;
|
||||||
@@ -162,7 +178,10 @@ public:
|
|||||||
void
|
void
|
||||||
missing_node (std::uint32_t seq) override
|
missing_node (std::uint32_t seq) override
|
||||||
{
|
{
|
||||||
WriteLog (lsERROR, Ledger) << "Missing node in " << seq;
|
auto j = app_.journal ("Ledger");
|
||||||
|
|
||||||
|
JLOG (j.error) <<
|
||||||
|
"Missing node in " << seq;
|
||||||
|
|
||||||
// prevent recursive invocation
|
// prevent recursive invocation
|
||||||
std::unique_lock <std::mutex> lock (maxSeqLock);
|
std::unique_lock <std::mutex> lock (maxSeqLock);
|
||||||
@@ -179,11 +198,9 @@ public:
|
|||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
||||||
// This can invoke the missing node handler
|
// This can invoke the missing node handler
|
||||||
uint256 hash = app_.getLedgerMaster().getHashBySeq (seq);
|
acquire (
|
||||||
|
app_.getLedgerMaster().getHashBySeq (seq),
|
||||||
if (hash.isNonZero())
|
seq);
|
||||||
app_.getInboundLedgers().acquire (
|
|
||||||
hash, seq, InboundLedger::fcGENERIC);
|
|
||||||
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
}
|
}
|
||||||
@@ -191,7 +208,8 @@ public:
|
|||||||
}
|
}
|
||||||
else if (maxSeq < seq)
|
else if (maxSeq < seq)
|
||||||
{
|
{
|
||||||
// We found a more recent ledger with a missing node
|
// We found a more recent ledger with a
|
||||||
|
// missing node
|
||||||
maxSeq = seq;
|
maxSeq = seq;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -199,14 +217,7 @@ public:
|
|||||||
void
|
void
|
||||||
missing_node (uint256 const& hash) override
|
missing_node (uint256 const& hash) override
|
||||||
{
|
{
|
||||||
if (hash.isNonZero())
|
acquire (hash, 0);
|
||||||
{
|
|
||||||
WriteLog (lsERROR, Ledger) << "Missing node in "
|
|
||||||
<< to_string (hash);
|
|
||||||
|
|
||||||
app_.getInboundLedgers ().acquire (
|
|
||||||
hash, 0, InboundLedger::fcGENERIC);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -225,6 +225,7 @@ int run (int argc, char** argv)
|
|||||||
("ledgerfile", po::value<std::string> (), "Load the specified ledger file.")
|
("ledgerfile", po::value<std::string> (), "Load the specified ledger file.")
|
||||||
("start", "Start from a fresh Ledger.")
|
("start", "Start from a fresh Ledger.")
|
||||||
("net", "Get the initial ledger from the network.")
|
("net", "Get the initial ledger from the network.")
|
||||||
|
("debug", "Enable normally suppressed debug logging")
|
||||||
("fg", "Run in the foreground.")
|
("fg", "Run in the foreground.")
|
||||||
("import", importText.c_str ())
|
("import", importText.c_str ())
|
||||||
("version", "Display the build version.")
|
("version", "Display the build version.")
|
||||||
@@ -421,8 +422,6 @@ int run (int argc, char** argv)
|
|||||||
if (!vm.count ("parameters"))
|
if (!vm.count ("parameters"))
|
||||||
{
|
{
|
||||||
auto logs = std::make_unique<Logs>();
|
auto logs = std::make_unique<Logs>();
|
||||||
auto timeKeeper = make_TimeKeeper(
|
|
||||||
logs->journal("TimeKeeper"));
|
|
||||||
|
|
||||||
if (vm.count ("quiet"))
|
if (vm.count ("quiet"))
|
||||||
logs->severity (beast::Journal::kFatal);
|
logs->severity (beast::Journal::kFatal);
|
||||||
@@ -431,6 +430,12 @@ int run (int argc, char** argv)
|
|||||||
else
|
else
|
||||||
logs->severity (beast::Journal::kInfo);
|
logs->severity (beast::Journal::kInfo);
|
||||||
|
|
||||||
|
if (vm.count ("debug"))
|
||||||
|
setDebugJournalSink (logs->get("Debug"));
|
||||||
|
|
||||||
|
auto timeKeeper = make_TimeKeeper(
|
||||||
|
logs->journal("TimeKeeper"));
|
||||||
|
|
||||||
auto app = make_Application(
|
auto app = make_Application(
|
||||||
std::move(config),
|
std::move(config),
|
||||||
std::move(logs),
|
std::move(logs),
|
||||||
|
|||||||
@@ -53,19 +53,24 @@ void PathState::reset(STAmount const& in, STAmount const& out)
|
|||||||
saInAct = in;
|
saInAct = in;
|
||||||
saOutAct = out;
|
saOutAct = out;
|
||||||
|
|
||||||
CondLog (inReq() > zero && inAct() >= inReq(),
|
if (inReq() > zero && inAct() >= inReq())
|
||||||
lsWARNING, RippleCalc)
|
{
|
||||||
<< "rippleCalc: DONE:"
|
JLOG (j_.warning)
|
||||||
<< " inAct()=" << inAct()
|
<< "rippleCalc: DONE:"
|
||||||
<< " inReq()=" << inReq();
|
<< " inAct()=" << inAct()
|
||||||
|
<< " inReq()=" << inReq();
|
||||||
|
}
|
||||||
|
|
||||||
assert (inReq() < zero || inAct() < inReq());
|
assert (inReq() < zero || inAct() < inReq());
|
||||||
// Error if done.
|
// Error if done.
|
||||||
|
|
||||||
CondLog (outAct() >= outReq(), lsWARNING, RippleCalc)
|
if (outAct() >= outReq())
|
||||||
<< "rippleCalc: ALREADY DONE:"
|
{
|
||||||
<< " saOutAct=" << outAct()
|
JLOG (j_.warning)
|
||||||
<< " saOutReq=" << outReq();
|
<< "rippleCalc: ALREADY DONE:"
|
||||||
|
<< " saOutAct=" << outAct()
|
||||||
|
<< " saOutReq=" << outReq();
|
||||||
|
}
|
||||||
|
|
||||||
assert(outAct() < outReq());
|
assert(outAct() < outReq());
|
||||||
assert (nodes().size () >= 2);
|
assert (nodes().size () >= 2);
|
||||||
|
|||||||
@@ -831,9 +831,13 @@ STPathSet& Pathfinder::addPathsForType (PathType const& pathType)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CondLog (mCompletePaths.size () != initialSize, lsDEBUG, Pathfinder)
|
if (mCompletePaths.size () != initialSize)
|
||||||
<< (mCompletePaths.size () - initialSize)
|
{
|
||||||
<< " complete paths added";
|
JLOG (j_.debug)
|
||||||
|
<< (mCompletePaths.size () - initialSize)
|
||||||
|
<< " complete paths added";
|
||||||
|
}
|
||||||
|
|
||||||
JLOG (j_.debug)
|
JLOG (j_.debug)
|
||||||
<< "getPaths> " << pathsOut.size () << " partial paths found";
|
<< "getPaths> " << pathsOut.size () << " partial paths found";
|
||||||
return pathsOut;
|
return pathsOut;
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ TER RippleCalc::rippleCalculate ()
|
|||||||
// This should never happen. Consider the path dry
|
// This should never happen. Consider the path dry
|
||||||
|
|
||||||
JLOG (j_.warning)
|
JLOG (j_.warning)
|
||||||
<< "rippelCalc: Non-dry path moves no funds";
|
<< "rippleCalc: Non-dry path moves no funds";
|
||||||
|
|
||||||
assert (false);
|
assert (false);
|
||||||
|
|
||||||
@@ -257,13 +257,15 @@ TER RippleCalc::rippleCalculate ()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CondLog (!pathState->inPass() || !pathState->outPass(),
|
if (!pathState->inPass() || !pathState->outPass())
|
||||||
lsDEBUG, RippleCalc)
|
{
|
||||||
<< "rippleCalc: better:"
|
JLOG (j_.debug)
|
||||||
<< " uQuality="
|
<< "rippleCalc: better:"
|
||||||
<< amountFromRate (pathState->quality())
|
<< " uQuality="
|
||||||
<< " inPass()=" << pathState->inPass()
|
<< amountFromRate (pathState->quality())
|
||||||
<< " saOutPass=" << pathState->outPass();
|
<< " inPass()=" << pathState->inPass()
|
||||||
|
<< " saOutPass=" << pathState->outPass();
|
||||||
|
}
|
||||||
|
|
||||||
assert (pathState->inPass() && pathState->outPass());
|
assert (pathState->inPass() && pathState->outPass());
|
||||||
|
|
||||||
@@ -293,16 +295,17 @@ TER RippleCalc::rippleCalculate ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
++iPass;
|
++iPass;
|
||||||
if (ShouldLog (lsDEBUG, RippleCalc))
|
|
||||||
|
if (j_.debug)
|
||||||
{
|
{
|
||||||
JLOG (j_.debug)
|
j_.debug
|
||||||
<< "rippleCalc: Summary:"
|
<< "rippleCalc: Summary:"
|
||||||
<< " Pass: " << iPass
|
<< " Pass: " << iPass
|
||||||
<< " Dry: " << iDry
|
<< " Dry: " << iDry
|
||||||
<< " Paths: " << pathStateList_.size ();
|
<< " Paths: " << pathStateList_.size ();
|
||||||
for (auto pathState: pathStateList_)
|
for (auto pathState: pathStateList_)
|
||||||
{
|
{
|
||||||
JLOG (j_.debug)
|
j_.debug
|
||||||
<< "rippleCalc: "
|
<< "rippleCalc: "
|
||||||
<< "Summary: " << pathState->index()
|
<< "Summary: " << pathState->index()
|
||||||
<< " rate: "
|
<< " rate: "
|
||||||
|
|||||||
@@ -338,10 +338,13 @@ TER PathCursor::deliverNodeForward (
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CondLog (saOutPassAct >= saOutFunded, lsWARNING, RippleCalc)
|
if (saOutPassAct >= saOutFunded)
|
||||||
<< "deliverNodeForward: TOO MUCH:"
|
{
|
||||||
<< " saOutPassAct=" << saOutPassAct
|
JLOG (j_.warning)
|
||||||
<< " saOutFunded=" << saOutFunded;
|
<< "deliverNodeForward: TOO MUCH:"
|
||||||
|
<< " saOutPassAct=" << saOutPassAct
|
||||||
|
<< " saOutFunded=" << saOutFunded;
|
||||||
|
}
|
||||||
|
|
||||||
assert (saOutPassAct < saOutFunded);
|
assert (saOutPassAct < saOutFunded);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -337,10 +337,13 @@ TER PathCursor::deliverNodeReverseImpl (
|
|||||||
previousNode().saRevDeliver += saInPassAct;
|
previousNode().saRevDeliver += saInPassAct;
|
||||||
}
|
}
|
||||||
|
|
||||||
CondLog (saOutAct > saOutReq, lsWARNING, RippleCalc)
|
if (saOutAct > saOutReq)
|
||||||
<< "deliverNodeReverse: TOO MUCH:"
|
{
|
||||||
<< " saOutAct=" << saOutAct
|
JLOG (j_.warning)
|
||||||
<< " saOutReq=" << saOutReq;
|
<< "deliverNodeReverse: TOO MUCH:"
|
||||||
|
<< " saOutAct=" << saOutAct
|
||||||
|
<< " saOutReq=" << saOutReq;
|
||||||
|
}
|
||||||
|
|
||||||
assert(saOutAct <= saOutReq);
|
assert(saOutAct <= saOutReq);
|
||||||
|
|
||||||
|
|||||||
@@ -39,31 +39,23 @@ void PathCursor::nextIncrement () const
|
|||||||
{
|
{
|
||||||
// The next state is what is available in preference order.
|
// The next state is what is available in preference order.
|
||||||
// This is calculated when referenced accounts changed.
|
// This is calculated when referenced accounts changed.
|
||||||
// VFALCO-FIXME this generates errors
|
|
||||||
// JLOG (j_.trace)
|
|
||||||
// << "nextIncrement: Path In: " << pathState_.getJson ();
|
|
||||||
|
|
||||||
auto status = liquidity();
|
auto status = liquidity();
|
||||||
|
|
||||||
if (status == tesSUCCESS)
|
if (status == tesSUCCESS)
|
||||||
{
|
{
|
||||||
auto isDry = pathState_.isDry();
|
if (pathState_.isDry())
|
||||||
CondLog (isDry, lsDEBUG, RippleCalc)
|
{
|
||||||
<< "nextIncrement: Error forwardLiquidity reported success"
|
JLOG (j_.debug)
|
||||||
<< " on dry path:"
|
<< "nextIncrement: success on dry path:"
|
||||||
<< " saOutPass=" << pathState_.outPass()
|
<< " outPass=" << pathState_.outPass()
|
||||||
<< " inPass()=" << pathState_.inPass();
|
<< " inPass=" << pathState_.inPass();
|
||||||
|
|
||||||
if (isDry)
|
|
||||||
Throw<std::runtime_error> ("Made no progress.");
|
Throw<std::runtime_error> ("Made no progress.");
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate relative quality.
|
// Calculate relative quality.
|
||||||
pathState_.setQuality(getRate (
|
pathState_.setQuality(getRate (
|
||||||
pathState_.outPass(), pathState_.inPass()));
|
pathState_.outPass(), pathState_.inPass()));
|
||||||
|
|
||||||
// VFALCO-FIXME this generates errors
|
|
||||||
// JLOG (j_.trace)
|
|
||||||
// << "nextIncrement: Path after forward: " << pathState_.getJson ();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -236,6 +236,22 @@ private:
|
|||||||
#define JLOG(x) if (!x) { } else x
|
#define JLOG(x) if (!x) { } else x
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Debug logging:
|
||||||
|
|
||||||
|
/** Returns the debug journal. The journal may drain to a null sink. */
|
||||||
|
beast::Journal const&
|
||||||
|
debugJournal();
|
||||||
|
|
||||||
|
/** Set the sink for the debug journal
|
||||||
|
|
||||||
|
This operation is not thread safe and should only be called
|
||||||
|
from a controlled context, when no other threads are in a
|
||||||
|
call to debugJournal.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
setDebugJournalSink(beast::Journal::Sink& sink);
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// VFALCO DEPRECATED Temporary transition function until interfaces injected
|
// VFALCO DEPRECATED Temporary transition function until interfaces injected
|
||||||
inline
|
inline
|
||||||
@@ -265,25 +281,6 @@ private:
|
|||||||
beast::Journal::Severity const severity_;
|
beast::Journal::Severity const severity_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// VFALCO DEPRECATED Inject beast::Journal instead
|
|
||||||
#define ShouldLog(s, k) \
|
|
||||||
::ripple::deprecatedLogs()[#k].active(::ripple::Logs::toSeverity (s))
|
|
||||||
|
|
||||||
// DEPRECATED
|
|
||||||
#define WriteLog(s, k) \
|
|
||||||
if (!ShouldLog(s, k)) \
|
|
||||||
do {} while (0); \
|
|
||||||
else \
|
|
||||||
::beast::Journal::Stream (::ripple::deprecatedLogs()[#k], \
|
|
||||||
::ripple::Logs::toSeverity(s))
|
|
||||||
// DEPRECATED
|
|
||||||
#define CondLog(c, s, k) \
|
|
||||||
if (!ShouldLog(s, k) || !(c)) \
|
|
||||||
do {} while(0); \
|
|
||||||
else \
|
|
||||||
::beast::Journal::Stream (::ripple::deprecatedLogs()[#k], \
|
|
||||||
::ripple::Logs::toSeverity(s))
|
|
||||||
|
|
||||||
} // ripple
|
} // ripple
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -329,4 +329,22 @@ Logs::format (std::string& output, std::string const& message,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
static std::unique_ptr<beast::Journal> debugJournal_;
|
||||||
|
|
||||||
|
beast::Journal const&
|
||||||
|
debugJournal()
|
||||||
|
{
|
||||||
|
if (!debugJournal_)
|
||||||
|
debugJournal_ = std::make_unique<beast::Journal>();
|
||||||
|
|
||||||
|
return *debugJournal_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
setDebugJournalSink(beast::Journal::Sink& sink)
|
||||||
|
{
|
||||||
|
debugJournal_ = std::make_unique<beast::Journal>(sink);
|
||||||
|
}
|
||||||
|
|
||||||
} // ripple
|
} // ripple
|
||||||
|
|||||||
@@ -52,10 +52,12 @@ T rangeCheckedCast (C c)
|
|||||||
std::numeric_limits<C>::is_signed &&
|
std::numeric_limits<C>::is_signed &&
|
||||||
c < std::numeric_limits<T>::lowest ()))
|
c < std::numeric_limits<T>::lowest ()))
|
||||||
{
|
{
|
||||||
WriteLog (lsERROR, RangeCheckedCast)
|
JLOG (debugJournal().error) << "rangeCheckedCast domain error:"
|
||||||
<< "Range error. Min: " << std::numeric_limits<T>::lowest ()
|
<< " value = " << c
|
||||||
<< " Max: " << std::numeric_limits<T>::max () << " Got: " << c;
|
<< " min = " << std::numeric_limits<T>::lowest ()
|
||||||
|
<< " max: " << std::numeric_limits<T>::max ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return static_cast<T>(c);
|
return static_cast<T>(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1435,7 +1435,7 @@ accountSend (ApplyView& view,
|
|||||||
? view.peek (keylet::account(uReceiverID))
|
? view.peek (keylet::account(uReceiverID))
|
||||||
: SLE::pointer ();
|
: SLE::pointer ();
|
||||||
|
|
||||||
if (ShouldLog (lsTRACE, View))
|
if (j.trace)
|
||||||
{
|
{
|
||||||
std::string sender_bal ("-");
|
std::string sender_bal ("-");
|
||||||
std::string receiver_bal ("-");
|
std::string receiver_bal ("-");
|
||||||
@@ -1446,7 +1446,7 @@ accountSend (ApplyView& view,
|
|||||||
if (receiver)
|
if (receiver)
|
||||||
receiver_bal = receiver->getFieldAmount (sfBalance).getFullText ();
|
receiver_bal = receiver->getFieldAmount (sfBalance).getFullText ();
|
||||||
|
|
||||||
JLOG (j.trace) << "accountSend> " <<
|
j.trace << "accountSend> " <<
|
||||||
to_string (uSenderID) << " (" << sender_bal <<
|
to_string (uSenderID) << " (" << sender_bal <<
|
||||||
") -> " << to_string (uReceiverID) << " (" << receiver_bal <<
|
") -> " << to_string (uReceiverID) << " (" << receiver_bal <<
|
||||||
") : " << saAmount.getFullText ();
|
") : " << saAmount.getFullText ();
|
||||||
@@ -1479,7 +1479,7 @@ accountSend (ApplyView& view,
|
|||||||
view.update (receiver);
|
view.update (receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ShouldLog (lsTRACE, View))
|
if (j.trace)
|
||||||
{
|
{
|
||||||
std::string sender_bal ("-");
|
std::string sender_bal ("-");
|
||||||
std::string receiver_bal ("-");
|
std::string receiver_bal ("-");
|
||||||
@@ -1490,7 +1490,7 @@ accountSend (ApplyView& view,
|
|||||||
if (receiver)
|
if (receiver)
|
||||||
receiver_bal = receiver->getFieldAmount (sfBalance).getFullText ();
|
receiver_bal = receiver->getFieldAmount (sfBalance).getFullText ();
|
||||||
|
|
||||||
JLOG (j.trace) << "accountSend< " <<
|
j.trace << "accountSend< " <<
|
||||||
to_string (uSenderID) << " (" << sender_bal <<
|
to_string (uSenderID) << " (" << sender_bal <<
|
||||||
") -> " << to_string (uReceiverID) << " (" << receiver_bal <<
|
") -> " << to_string (uReceiverID) << " (" << receiver_bal <<
|
||||||
") : " << saAmount.getFullText ();
|
") : " << saAmount.getFullText ();
|
||||||
|
|||||||
@@ -893,10 +893,10 @@ public:
|
|||||||
// <-- { method: xyz, params: [... ] } or { error: ..., ... }
|
// <-- { method: xyz, params: [... ] } or { error: ..., ... }
|
||||||
Json::Value parseCommand (std::string strMethod, Json::Value jvParams, bool allowAnyCommand)
|
Json::Value parseCommand (std::string strMethod, Json::Value jvParams, bool allowAnyCommand)
|
||||||
{
|
{
|
||||||
if (ShouldLog (lsTRACE, RPCParser))
|
if (j_.trace)
|
||||||
{
|
{
|
||||||
JLOG (j_.trace) << "RPC method:" << strMethod;
|
j_.trace << "Method: '" << strMethod << "'";
|
||||||
JLOG (j_.trace) << "RPC params:" << jvParams;
|
j_.trace << "Params: " << jvParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Command
|
struct Command
|
||||||
|
|||||||
@@ -151,7 +151,6 @@ public:
|
|||||||
bool getVL (Blob& objectVL, int offset, int& length) const;
|
bool getVL (Blob& objectVL, int offset, int& length) const;
|
||||||
bool getVLLength (int& length, int offset) const;
|
bool getVLLength (int& length, int offset) const;
|
||||||
|
|
||||||
bool getFieldID (int& type, int& name, int offset) const;
|
|
||||||
int addFieldID (int type, int name);
|
int addFieldID (int type, int name);
|
||||||
int addFieldID (SerializedTypeID type, int name)
|
int addFieldID (SerializedTypeID type, int name)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -812,12 +812,6 @@ amountFromJson (SField const& name, Json::Value const& v)
|
|||||||
|
|
||||||
if (v.isObject ())
|
if (v.isObject ())
|
||||||
{
|
{
|
||||||
WriteLog (lsTRACE, STAmount) <<
|
|
||||||
"value='" << v[jss::value].asString () <<
|
|
||||||
"', currency='" << v["currency"].asString () <<
|
|
||||||
"', issuer='" << v["issuer"].asString () <<
|
|
||||||
"')";
|
|
||||||
|
|
||||||
value = v[jss::value];
|
value = v[jss::value];
|
||||||
currency = v[jss::currency];
|
currency = v[jss::currency];
|
||||||
issuer = v[jss::issuer];
|
issuer = v[jss::issuer];
|
||||||
@@ -916,7 +910,7 @@ amountFromJsonNoThrow (STAmount& result, Json::Value const& jvSource)
|
|||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
WriteLog (lsDEBUG, STAmount) <<
|
JLOG (debugJournal().debug) <<
|
||||||
"amountFromJsonNoThrow: caught: " << e.what ();
|
"amountFromJsonNoThrow: caught: " << e.what ();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -1104,9 +1098,6 @@ canonicalizeRound (bool native, std::uint64_t& value, int& offset, bool roundUp)
|
|||||||
if (!roundUp) // canonicalize already rounds down
|
if (!roundUp) // canonicalize already rounds down
|
||||||
return;
|
return;
|
||||||
|
|
||||||
WriteLog (lsTRACE, STAmount)
|
|
||||||
<< "canonicalizeRound< " << value << ":" << offset;
|
|
||||||
|
|
||||||
if (native)
|
if (native)
|
||||||
{
|
{
|
||||||
if (offset < 0)
|
if (offset < 0)
|
||||||
@@ -1137,9 +1128,6 @@ canonicalizeRound (bool native, std::uint64_t& value, int& offset, bool roundUp)
|
|||||||
value /= 10;
|
value /= 10;
|
||||||
++offset;
|
++offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteLog (lsTRACE, STAmount)
|
|
||||||
<< "canonicalizeRound> " << value << ":" << offset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STAmount
|
STAmount
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ STArray::STArray (SerialIter& sit, SField const& f)
|
|||||||
|
|
||||||
if ((type == STI_OBJECT) && (field == 1))
|
if ((type == STI_OBJECT) && (field == 1))
|
||||||
{
|
{
|
||||||
WriteLog (lsWARNING, STObject) <<
|
JLOG (debugJournal().warning) <<
|
||||||
"Encountered array with end of object marker";
|
"Encountered array with end of object marker";
|
||||||
Throw<std::runtime_error> ("Illegal terminator in array");
|
Throw<std::runtime_error> ("Illegal terminator in array");
|
||||||
}
|
}
|
||||||
@@ -85,14 +85,15 @@ STArray::STArray (SerialIter& sit, SField const& f)
|
|||||||
|
|
||||||
if (fn.isInvalid ())
|
if (fn.isInvalid ())
|
||||||
{
|
{
|
||||||
WriteLog (lsTRACE, STObject) <<
|
JLOG (debugJournal().trace) <<
|
||||||
"Unknown field: " << type << "/" << field;
|
"Unknown field: " << type << "/" << field;
|
||||||
Throw<std::runtime_error> ("Unknown field");
|
Throw<std::runtime_error> ("Unknown field");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fn.fieldType != STI_OBJECT)
|
if (fn.fieldType != STI_OBJECT)
|
||||||
{
|
{
|
||||||
WriteLog (lsTRACE, STObject) << "Array contains non-object";
|
JLOG (debugJournal().trace) <<
|
||||||
|
"Array contains non-object";
|
||||||
Throw<std::runtime_error> ("Non-object in array");
|
Throw<std::runtime_error> ("Non-object in array");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,16 +173,8 @@ void STArray::add (Serializer& s) const
|
|||||||
|
|
||||||
bool STArray::isEquivalent (const STBase& t) const
|
bool STArray::isEquivalent (const STBase& t) const
|
||||||
{
|
{
|
||||||
const STArray* v = dynamic_cast<const STArray*> (&t);
|
auto v = dynamic_cast<const STArray*> (&t);
|
||||||
|
return v != nullptr && v_ == v->v_;
|
||||||
if (!v)
|
|
||||||
{
|
|
||||||
WriteLog (lsDEBUG, STObject) <<
|
|
||||||
"notEquiv " << getFullText() << " not array";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return v_ == v->v_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void STArray::sort (bool (*compare) (const STObject&, const STObject&))
|
void STArray::sort (bool (*compare) (const STObject&, const STObject&))
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ STUInt8::getText () const
|
|||||||
|
|
||||||
if (transResultInfo (static_cast<TER> (value_), token, human))
|
if (transResultInfo (static_cast<TER> (value_), token, human))
|
||||||
return human;
|
return human;
|
||||||
|
|
||||||
|
JLOG (debugJournal().warning)
|
||||||
|
<< "Unknown result code in metadata: " << value_;
|
||||||
}
|
}
|
||||||
|
|
||||||
return beast::lexicalCastThrow <std::string> (value_);
|
return beast::lexicalCastThrow <std::string> (value_);
|
||||||
@@ -66,9 +69,9 @@ STUInt8::getJson (int) const
|
|||||||
|
|
||||||
if (transResultInfo (static_cast<TER> (value_), token, human))
|
if (transResultInfo (static_cast<TER> (value_), token, human))
|
||||||
return token;
|
return token;
|
||||||
else
|
|
||||||
WriteLog (lsWARNING, STBase)
|
JLOG (debugJournal().warning)
|
||||||
<< "Unknown result code in metadata: " << value_;
|
<< "Unknown result code in metadata: " << value_;
|
||||||
}
|
}
|
||||||
|
|
||||||
return value_;
|
return value_;
|
||||||
|
|||||||
@@ -78,9 +78,12 @@ void STLedgerEntry::setSLEType ()
|
|||||||
type_ = mFormat->getType ();
|
type_ = mFormat->getType ();
|
||||||
if (!setType (mFormat->elements))
|
if (!setType (mFormat->elements))
|
||||||
{
|
{
|
||||||
WriteLog (lsWARNING, SerializedLedger)
|
if (auto j = debugJournal().warning)
|
||||||
<< "Ledger entry not valid for type " << mFormat->getName ();
|
{
|
||||||
WriteLog (lsWARNING, SerializedLedger) << getJson (0);
|
j << "Ledger entry not valid for type " << mFormat->getName ();
|
||||||
|
j << "Object: " << getJson (0);
|
||||||
|
}
|
||||||
|
|
||||||
Throw<std::runtime_error> ("ledger entry not valid for type");
|
Throw<std::runtime_error> ("ledger entry not valid for type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,7 +140,9 @@ bool STLedgerEntry::thread (uint256 const& txID, std::uint32_t ledgerSeq,
|
|||||||
uint256& prevTxID, std::uint32_t& prevLedgerID)
|
uint256& prevTxID, std::uint32_t& prevLedgerID)
|
||||||
{
|
{
|
||||||
uint256 oldPrevTxID = getFieldH256 (sfPreviousTxnID);
|
uint256 oldPrevTxID = getFieldH256 (sfPreviousTxnID);
|
||||||
WriteLog (lsTRACE, SerializedLedger) << "Thread Tx:" << txID << " prev:" << oldPrevTxID;
|
|
||||||
|
JLOG (debugJournal().trace)
|
||||||
|
<< "Thread Tx:" << txID << " prev:" << oldPrevTxID;
|
||||||
|
|
||||||
if (oldPrevTxID == txID)
|
if (oldPrevTxID == txID)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -113,9 +113,9 @@ bool STObject::setType (const SOTemplate& type)
|
|||||||
{
|
{
|
||||||
if ((e->flags == SOE_DEFAULT) && iter->get().isDefault())
|
if ((e->flags == SOE_DEFAULT) && iter->get().isDefault())
|
||||||
{
|
{
|
||||||
WriteLog (lsWARNING, STObject) <<
|
JLOG (debugJournal().warning)
|
||||||
"setType( " << getFName ().getName () <<
|
<< "setType(" << getFName().getName()
|
||||||
" ) invalid default " << e->e_field.fieldName;
|
<< "): explicit default " << e->e_field.fieldName;
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
v.emplace_back(std::move(*iter));
|
v.emplace_back(std::move(*iter));
|
||||||
@@ -125,9 +125,9 @@ bool STObject::setType (const SOTemplate& type)
|
|||||||
{
|
{
|
||||||
if (e->flags == SOE_REQUIRED)
|
if (e->flags == SOE_REQUIRED)
|
||||||
{
|
{
|
||||||
WriteLog (lsWARNING, STObject) <<
|
JLOG (debugJournal().warning)
|
||||||
"setType( " << getFName ().getName () <<
|
<< "setType(" << getFName().getName()
|
||||||
" ) invalid missing " << e->e_field.fieldName;
|
<< "): missing " << e->e_field.fieldName;
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
v.emplace_back(detail::nonPresentObject, e->e_field);
|
v.emplace_back(detail::nonPresentObject, e->e_field);
|
||||||
@@ -138,9 +138,9 @@ bool STObject::setType (const SOTemplate& type)
|
|||||||
// Anything left over in the object must be discardable
|
// Anything left over in the object must be discardable
|
||||||
if (! e->getFName().isDiscardable())
|
if (! e->getFName().isDiscardable())
|
||||||
{
|
{
|
||||||
WriteLog (lsWARNING, STObject) <<
|
JLOG (debugJournal().warning)
|
||||||
"setType( " << getFName ().getName () <<
|
<< "setType(" << getFName().getName()
|
||||||
" ) invalid leftover " << e->getFName ().getName ();
|
<< "): non-discardable leftover " << e->getFName().getName ();
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -208,8 +208,8 @@ bool STObject::set (SerialIter& sit, int depth)
|
|||||||
|
|
||||||
if ((type == STI_ARRAY) && (field == 1))
|
if ((type == STI_ARRAY) && (field == 1))
|
||||||
{
|
{
|
||||||
WriteLog (lsWARNING, STObject) <<
|
JLOG (debugJournal().warning)
|
||||||
"Encountered object with end of array marker";
|
<< "Encountered object with end of array marker";
|
||||||
Throw<std::runtime_error> ("Illegal terminator in object");
|
Throw<std::runtime_error> ("Illegal terminator in object");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,9 +221,9 @@ bool STObject::set (SerialIter& sit, int depth)
|
|||||||
|
|
||||||
if (fn.isInvalid ())
|
if (fn.isInvalid ())
|
||||||
{
|
{
|
||||||
WriteLog (lsWARNING, STObject) <<
|
JLOG (debugJournal().warning)
|
||||||
"Unknown field: field_type=" << type <<
|
<< "Unknown field: field_type=" << type
|
||||||
", field_name=" << field;
|
<< ", field_name=" << field;
|
||||||
Throw<std::runtime_error> ("Unknown field");
|
Throw<std::runtime_error> ("Unknown field");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,11 +304,7 @@ bool STObject::isEquivalent (const STBase& t) const
|
|||||||
const STObject* v = dynamic_cast<const STObject*> (&t);
|
const STObject* v = dynamic_cast<const STObject*> (&t);
|
||||||
|
|
||||||
if (!v)
|
if (!v)
|
||||||
{
|
|
||||||
WriteLog (lsDEBUG, STObject) <<
|
|
||||||
"notEquiv " << getFullText() << " not object";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (mType != nullptr && (v->mType == mType))
|
if (mType != nullptr && (v->mType == mType))
|
||||||
return equivalentSTObjectSameTemplate (*this, *v);
|
return equivalentSTObjectSameTemplate (*this, *v);
|
||||||
@@ -727,12 +723,7 @@ bool STObject::operator== (const STObject& obj) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!match)
|
if (!match)
|
||||||
{
|
|
||||||
WriteLog (lsTRACE, STObject) <<
|
|
||||||
"STObject::operator==: no match for " <<
|
|
||||||
t1->getFName ().getName ();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -744,11 +735,7 @@ bool STObject::operator== (const STObject& obj) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fields != matches)
|
if (fields != matches)
|
||||||
{
|
|
||||||
WriteLog (lsTRACE, STObject) << "STObject::operator==: " <<
|
|
||||||
fields << " fields, " << matches << " matches";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ STPathSet::STPathSet (SerialIter& sit, SField const& name)
|
|||||||
{
|
{
|
||||||
if (path.empty ())
|
if (path.empty ())
|
||||||
{
|
{
|
||||||
WriteLog (lsINFO, STBase)
|
JLOG (debugJournal().info)
|
||||||
<< "STPathSet: Empty path.";
|
<< "Empty path in pathset";
|
||||||
Throw<std::runtime_error> ("empty path");
|
Throw<std::runtime_error> ("empty path");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,9 +77,8 @@ STPathSet::STPathSet (SerialIter& sit, SField const& name)
|
|||||||
}
|
}
|
||||||
else if (iType & ~STPathElement::typeAll)
|
else if (iType & ~STPathElement::typeAll)
|
||||||
{
|
{
|
||||||
WriteLog (lsINFO, STBase)
|
JLOG (debugJournal().info)
|
||||||
<< "STPathSet: Bad path element: " << iType;
|
<< "Bad path element " << iType << " in pathset";
|
||||||
|
|
||||||
Throw<std::runtime_error> ("bad path element");
|
Throw<std::runtime_error> ("bad path element");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ STValidation::STValidation (SerialIter& sit, bool checkSignature)
|
|||||||
|
|
||||||
if (checkSignature && !isValid ())
|
if (checkSignature && !isValid ())
|
||||||
{
|
{
|
||||||
WriteLog (lsTRACE, Ledger) << "Invalid validation " << getJson (0);
|
JLOG (debugJournal().trace)
|
||||||
|
<< "Invalid validation" << getJson (0);
|
||||||
Throw<std::runtime_error> ("Invalid validation");
|
Throw<std::runtime_error> ("Invalid validation");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,7 +113,8 @@ bool STValidation::isValid (uint256 const& signingHash) const
|
|||||||
}
|
}
|
||||||
catch (std::exception const&)
|
catch (std::exception const&)
|
||||||
{
|
{
|
||||||
WriteLog (lsINFO, Ledger) << "exception validating validation";
|
JLOG (debugJournal().info)
|
||||||
|
<< "Exception validating validation";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,46 +148,6 @@ int Serializer::addFieldID (int type, int name)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Serializer::getFieldID (int& type, int& name, int offset) const
|
|
||||||
{
|
|
||||||
if (!get8 (type, offset))
|
|
||||||
{
|
|
||||||
WriteLog (lsWARNING, Serializer) << "gFID: unable to get type";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
name = type & 15;
|
|
||||||
type >>= 4;
|
|
||||||
|
|
||||||
if (type == 0)
|
|
||||||
{
|
|
||||||
// uncommon type
|
|
||||||
if (!get8 (type, ++offset))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if ((type == 0) || (type < 16))
|
|
||||||
{
|
|
||||||
WriteLog (lsWARNING, Serializer) << "gFID: uncommon type out of range " << type;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (name == 0)
|
|
||||||
{
|
|
||||||
// uncommon name
|
|
||||||
if (!get8 (name, ++offset))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if ((name == 0) || (name < 16))
|
|
||||||
{
|
|
||||||
WriteLog (lsWARNING, Serializer) << "gFID: uncommon name out of range " << name;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Serializer::add8 (unsigned char byte)
|
int Serializer::add8 (unsigned char byte)
|
||||||
{
|
{
|
||||||
int ret = mData.size ();
|
int ret = mData.size ();
|
||||||
|
|||||||
@@ -26,30 +26,33 @@ namespace log {
|
|||||||
void websocketLog (
|
void websocketLog (
|
||||||
websocketpp_02::log::alevel::value v, std::string const& entry)
|
websocketpp_02::log::alevel::value v, std::string const& entry)
|
||||||
{
|
{
|
||||||
using namespace ripple;
|
auto const isTrace =
|
||||||
auto isTrace = v == websocketpp_02::log::alevel::DEVEL ||
|
v == websocketpp_02::log::alevel::DEVEL ||
|
||||||
v == websocketpp_02::log::alevel::DEBUG_CLOSE;
|
v == websocketpp_02::log::alevel::DEBUG_CLOSE;
|
||||||
|
|
||||||
WriteLog(isTrace ? lsTRACE : lsDEBUG, WebSocket) << entry;
|
auto journal = ripple::debugJournal();
|
||||||
|
|
||||||
|
if (isTrace)
|
||||||
|
JLOG (journal.trace) << entry;
|
||||||
|
else
|
||||||
|
JLOG (journal.debug) << entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void websocketLog (
|
void websocketLog (
|
||||||
websocketpp_02::log::elevel::value v, std::string const& entry)
|
websocketpp_02::log::elevel::value v, std::string const& entry)
|
||||||
{
|
{
|
||||||
using namespace ripple;
|
auto journal = ripple::debugJournal();
|
||||||
|
|
||||||
LogSeverity s = lsDEBUG;
|
|
||||||
|
|
||||||
if ((v & websocketpp_02::log::elevel::INFO) != 0)
|
if ((v & websocketpp_02::log::elevel::INFO) != 0)
|
||||||
s = lsINFO;
|
JLOG (journal.info) << entry;
|
||||||
else if ((v & websocketpp_02::log::elevel::FATAL) != 0)
|
else if ((v & websocketpp_02::log::elevel::FATAL) != 0)
|
||||||
s = lsFATAL;
|
JLOG (journal.fatal) << entry;
|
||||||
else if ((v & websocketpp_02::log::elevel::RERROR) != 0)
|
else if ((v & websocketpp_02::log::elevel::RERROR) != 0)
|
||||||
s = lsERROR;
|
JLOG (journal.error) << entry;
|
||||||
else if ((v & websocketpp_02::log::elevel::WARN) != 0)
|
else if ((v & websocketpp_02::log::elevel::WARN) != 0)
|
||||||
s = lsWARNING;
|
JLOG (journal.warning) << entry;
|
||||||
|
else
|
||||||
WriteLog(s, WebSocket) << entry;
|
JLOG (journal.debug) << entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,90 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of rippled: https://github.com/ripple/rippled
|
|
||||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef RIPPLED_RIPPLE_WEBSOCKET_LOGGER_H
|
|
||||||
#define RIPPLED_RIPPLE_WEBSOCKET_LOGGER_H
|
|
||||||
|
|
||||||
#include <websocketpp/logger/levels.hpp>
|
|
||||||
#include <ripple/basics/Log.h>
|
|
||||||
|
|
||||||
namespace ripple {
|
|
||||||
namespace websocket {
|
|
||||||
|
|
||||||
using LogLevel = websocketpp::log::level;
|
|
||||||
enum class LoggerType {error, access};
|
|
||||||
|
|
||||||
template <LoggerType>
|
|
||||||
LogSeverity getSeverity (LogLevel);
|
|
||||||
|
|
||||||
template <LoggerType loggerType>
|
|
||||||
class Logger {
|
|
||||||
public:
|
|
||||||
using Hint = websocketpp::log::channel_type_hint::value;
|
|
||||||
|
|
||||||
explicit Logger (Hint) {}
|
|
||||||
Logger (LogLevel, Hint) {}
|
|
||||||
void set_channels (LogLevel) {}
|
|
||||||
void clear_channels (LogLevel) {}
|
|
||||||
|
|
||||||
void write (LogLevel level, std::string const& s)
|
|
||||||
{
|
|
||||||
WriteLog (getSeverity <loggerType> (level), WebSocket) << s;
|
|
||||||
}
|
|
||||||
|
|
||||||
void write (LogLevel level, const char* s)
|
|
||||||
{
|
|
||||||
write (level, std::string (s));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool static_test (LogLevel) const {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool dynamic_test (LogLevel) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
LogSeverity getSeverity <LoggerType::error> (LogLevel level)
|
|
||||||
{
|
|
||||||
if (level & websocketpp::log::elevel::info)
|
|
||||||
return lsINFO;
|
|
||||||
if (level & websocketpp::log::elevel::fatal)
|
|
||||||
return lsFATAL;
|
|
||||||
if (level & websocketpp::log::elevel::rerror)
|
|
||||||
return lsERROR;
|
|
||||||
if (level & websocketpp::log::elevel::warn)
|
|
||||||
return lsWARNING;
|
|
||||||
return lsDEBUG;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
LogSeverity getSeverity <LoggerType::access> (LogLevel level)
|
|
||||||
{
|
|
||||||
auto isTrace = level == websocketpp::log::alevel::devel ||
|
|
||||||
level == websocketpp::log::alevel::debug_close;
|
|
||||||
|
|
||||||
return isTrace ? lsTRACE : lsDEBUG;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // websocket
|
|
||||||
} // ripple
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Reference in New Issue
Block a user