mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-24 13:05:53 +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);
|
||||
}
|
||||
|
||||
if (ShouldLog (lsINFO, Ledger) && !missingNodes1.empty ())
|
||||
if (j.info && !missingNodes1.empty ())
|
||||
{
|
||||
JLOG (j.info)
|
||||
<< missingNodes1.size () << " missing account node(s)";
|
||||
JLOG (j.info)
|
||||
<< "First: " << missingNodes1[0];
|
||||
j.info << missingNodes1.size () << " missing account node(s)";
|
||||
j.info << "First: " << missingNodes1[0];
|
||||
}
|
||||
|
||||
if (txMap_->getHash().isZero() &&
|
||||
@@ -809,12 +807,10 @@ bool Ledger::walkLedger (beast::Journal j) const
|
||||
txMap_->walkMap (missingNodes2, 32);
|
||||
}
|
||||
|
||||
if (ShouldLog (lsINFO, Ledger) && !missingNodes2.empty ())
|
||||
if (j.info && !missingNodes2.empty ())
|
||||
{
|
||||
JLOG (j.info)
|
||||
<< missingNodes2.size () << " missing transaction node(s)";
|
||||
JLOG (j.info)
|
||||
<< "First: " << missingNodes2[0];
|
||||
j.info << missingNodes2.size () << " missing transaction node(s)";
|
||||
j.info << "First: " << missingNodes2[0];
|
||||
}
|
||||
|
||||
return missingNodes1.empty () && missingNodes2.empty ();
|
||||
@@ -1057,16 +1053,15 @@ static bool saveValidatedLedger (
|
||||
sql += ")";
|
||||
}
|
||||
sql += ";";
|
||||
if (ShouldLog (lsTRACE, Ledger))
|
||||
{
|
||||
JLOG (j.trace) << "ActTx: " << sql;
|
||||
}
|
||||
*db << sql;
|
||||
}
|
||||
else
|
||||
{
|
||||
JLOG (j.warning)
|
||||
<< "Transaction in ledger " << seq
|
||||
<< " affects no accounts";
|
||||
}
|
||||
|
||||
*db <<
|
||||
(STTx::getMetaSQLInsertReplaceHeader () +
|
||||
|
||||
@@ -367,15 +367,17 @@ void LedgerConsensusImp::mapCompleteInternal (
|
||||
std::shared_ptr<SHAMap> const& map,
|
||||
bool acquired)
|
||||
{
|
||||
CondLog (acquired, lsDEBUG, LedgerConsensus)
|
||||
<< "We have acquired TXS " << hash;
|
||||
if (acquired)
|
||||
{
|
||||
JLOG (j_.trace) << "We have acquired txs " << hash;
|
||||
}
|
||||
|
||||
if (!map) // If the map was invalid
|
||||
{
|
||||
// this is an invalid/corrupt map
|
||||
mAcquired[hash] = map;
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -387,9 +389,7 @@ void LedgerConsensusImp::mapCompleteInternal (
|
||||
if (it != mAcquired.end ())
|
||||
{
|
||||
if (it->second)
|
||||
{
|
||||
return; // we already have this map
|
||||
}
|
||||
|
||||
// We previously failed to acquire this map, now we have it
|
||||
mAcquired.erase (hash);
|
||||
@@ -422,14 +422,20 @@ void LedgerConsensusImp::mapCompleteInternal (
|
||||
createDisputes (it2->second, map);
|
||||
}
|
||||
else if (!mOurPosition)
|
||||
{
|
||||
JLOG (j_.debug)
|
||||
<< "Not creating disputes: no position yet.";
|
||||
}
|
||||
else if (mOurPosition->isBowOut ())
|
||||
{
|
||||
JLOG (j_.warning)
|
||||
<< "Not creating disputes: not participating.";
|
||||
}
|
||||
else
|
||||
{
|
||||
JLOG (j_.debug)
|
||||
<< "Not creating disputes: identical position.";
|
||||
}
|
||||
|
||||
mAcquired[hash] = map;
|
||||
|
||||
@@ -446,11 +452,11 @@ void LedgerConsensusImp::mapCompleteInternal (
|
||||
{
|
||||
adjustCount (map, peers);
|
||||
}
|
||||
else
|
||||
else if (acquired)
|
||||
{
|
||||
CondLog (acquired, lsWARNING, LedgerConsensus)
|
||||
<< "By the time we got the map "
|
||||
<< hash << " no peers were proposing it";
|
||||
JLOG (j_.warning)
|
||||
<< "By the time we got the map " << hash
|
||||
<< " no peers were proposing it";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1623,10 +1629,14 @@ void LedgerConsensusImp::updateOurPositions ()
|
||||
}
|
||||
}
|
||||
|
||||
CondLog (!mHaveCloseTimeConsensus, lsDEBUG, LedgerConsensus)
|
||||
<< "No CT consensus: Proposers:" << mPeerPositions.size ()
|
||||
<< " Proposing:" << (mProposing ? "yes" : "no") << " Thresh:"
|
||||
<< threshConsensus << " Pos:" << closeTime.time_since_epoch().count();
|
||||
if (!mHaveCloseTimeConsensus)
|
||||
{
|
||||
JLOG (j_.debug) << "No CT consensus:"
|
||||
<< " 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
|
||||
|
||||
@@ -596,9 +596,14 @@ LedgerMaster::fixMismatch (Ledger::ref ledger)
|
||||
if (otherLedger && (otherLedger->getHash () == *hash))
|
||||
{
|
||||
// we closed the seam
|
||||
CondLog (invalidate != 0, lsWARNING, LedgerMaster) <<
|
||||
"Match at " << lSeq << ", " << invalidate <<
|
||||
" prior ledgers invalidated";
|
||||
if (invalidate != 0)
|
||||
{
|
||||
JLOG (m_journal.warning)
|
||||
<< "Match at " << lSeq
|
||||
<< ", " << invalidate
|
||||
<< " prior ledgers invalidated";
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -609,8 +614,11 @@ LedgerMaster::fixMismatch (Ledger::ref ledger)
|
||||
}
|
||||
|
||||
// all prior ledgers invalidated
|
||||
CondLog (invalidate != 0, lsWARNING, LedgerMaster) << "All " <<
|
||||
invalidate << " prior ledgers invalidated";
|
||||
if (invalidate != 0)
|
||||
{
|
||||
JLOG (m_journal.warning) <<
|
||||
"All " << invalidate << " prior ledgers invalidated";
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -100,6 +100,22 @@ private:
|
||||
std::uint32_t maxSeq = 0;
|
||||
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:
|
||||
AppFamily (AppFamily const&) = delete;
|
||||
AppFamily& operator= (AppFamily const&) = delete;
|
||||
@@ -162,7 +178,10 @@ public:
|
||||
void
|
||||
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
|
||||
std::unique_lock <std::mutex> lock (maxSeqLock);
|
||||
@@ -179,11 +198,9 @@ public:
|
||||
lock.unlock();
|
||||
|
||||
// This can invoke the missing node handler
|
||||
uint256 hash = app_.getLedgerMaster().getHashBySeq (seq);
|
||||
|
||||
if (hash.isNonZero())
|
||||
app_.getInboundLedgers().acquire (
|
||||
hash, seq, InboundLedger::fcGENERIC);
|
||||
acquire (
|
||||
app_.getLedgerMaster().getHashBySeq (seq),
|
||||
seq);
|
||||
|
||||
lock.lock();
|
||||
}
|
||||
@@ -191,7 +208,8 @@ public:
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -199,14 +217,7 @@ public:
|
||||
void
|
||||
missing_node (uint256 const& hash) override
|
||||
{
|
||||
if (hash.isNonZero())
|
||||
{
|
||||
WriteLog (lsERROR, Ledger) << "Missing node in "
|
||||
<< to_string (hash);
|
||||
|
||||
app_.getInboundLedgers ().acquire (
|
||||
hash, 0, InboundLedger::fcGENERIC);
|
||||
}
|
||||
acquire (hash, 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -225,6 +225,7 @@ int run (int argc, char** argv)
|
||||
("ledgerfile", po::value<std::string> (), "Load the specified ledger file.")
|
||||
("start", "Start from a fresh Ledger.")
|
||||
("net", "Get the initial ledger from the network.")
|
||||
("debug", "Enable normally suppressed debug logging")
|
||||
("fg", "Run in the foreground.")
|
||||
("import", importText.c_str ())
|
||||
("version", "Display the build version.")
|
||||
@@ -421,8 +422,6 @@ int run (int argc, char** argv)
|
||||
if (!vm.count ("parameters"))
|
||||
{
|
||||
auto logs = std::make_unique<Logs>();
|
||||
auto timeKeeper = make_TimeKeeper(
|
||||
logs->journal("TimeKeeper"));
|
||||
|
||||
if (vm.count ("quiet"))
|
||||
logs->severity (beast::Journal::kFatal);
|
||||
@@ -431,6 +430,12 @@ int run (int argc, char** argv)
|
||||
else
|
||||
logs->severity (beast::Journal::kInfo);
|
||||
|
||||
if (vm.count ("debug"))
|
||||
setDebugJournalSink (logs->get("Debug"));
|
||||
|
||||
auto timeKeeper = make_TimeKeeper(
|
||||
logs->journal("TimeKeeper"));
|
||||
|
||||
auto app = make_Application(
|
||||
std::move(config),
|
||||
std::move(logs),
|
||||
|
||||
@@ -53,19 +53,24 @@ void PathState::reset(STAmount const& in, STAmount const& out)
|
||||
saInAct = in;
|
||||
saOutAct = out;
|
||||
|
||||
CondLog (inReq() > zero && inAct() >= inReq(),
|
||||
lsWARNING, RippleCalc)
|
||||
if (inReq() > zero && inAct() >= inReq())
|
||||
{
|
||||
JLOG (j_.warning)
|
||||
<< "rippleCalc: DONE:"
|
||||
<< " inAct()=" << inAct()
|
||||
<< " inReq()=" << inReq();
|
||||
}
|
||||
|
||||
assert (inReq() < zero || inAct() < inReq());
|
||||
// Error if done.
|
||||
|
||||
CondLog (outAct() >= outReq(), lsWARNING, RippleCalc)
|
||||
if (outAct() >= outReq())
|
||||
{
|
||||
JLOG (j_.warning)
|
||||
<< "rippleCalc: ALREADY DONE:"
|
||||
<< " saOutAct=" << outAct()
|
||||
<< " saOutReq=" << outReq();
|
||||
}
|
||||
|
||||
assert(outAct() < outReq());
|
||||
assert (nodes().size () >= 2);
|
||||
|
||||
@@ -831,9 +831,13 @@ STPathSet& Pathfinder::addPathsForType (PathType const& pathType)
|
||||
break;
|
||||
}
|
||||
|
||||
CondLog (mCompletePaths.size () != initialSize, lsDEBUG, Pathfinder)
|
||||
if (mCompletePaths.size () != initialSize)
|
||||
{
|
||||
JLOG (j_.debug)
|
||||
<< (mCompletePaths.size () - initialSize)
|
||||
<< " complete paths added";
|
||||
}
|
||||
|
||||
JLOG (j_.debug)
|
||||
<< "getPaths> " << pathsOut.size () << " partial paths found";
|
||||
return pathsOut;
|
||||
|
||||
@@ -248,7 +248,7 @@ TER RippleCalc::rippleCalculate ()
|
||||
// This should never happen. Consider the path dry
|
||||
|
||||
JLOG (j_.warning)
|
||||
<< "rippelCalc: Non-dry path moves no funds";
|
||||
<< "rippleCalc: Non-dry path moves no funds";
|
||||
|
||||
assert (false);
|
||||
|
||||
@@ -257,13 +257,15 @@ TER RippleCalc::rippleCalculate ()
|
||||
}
|
||||
else
|
||||
{
|
||||
CondLog (!pathState->inPass() || !pathState->outPass(),
|
||||
lsDEBUG, RippleCalc)
|
||||
if (!pathState->inPass() || !pathState->outPass())
|
||||
{
|
||||
JLOG (j_.debug)
|
||||
<< "rippleCalc: better:"
|
||||
<< " uQuality="
|
||||
<< amountFromRate (pathState->quality())
|
||||
<< " inPass()=" << pathState->inPass()
|
||||
<< " saOutPass=" << pathState->outPass();
|
||||
}
|
||||
|
||||
assert (pathState->inPass() && pathState->outPass());
|
||||
|
||||
@@ -293,16 +295,17 @@ TER RippleCalc::rippleCalculate ()
|
||||
}
|
||||
|
||||
++iPass;
|
||||
if (ShouldLog (lsDEBUG, RippleCalc))
|
||||
|
||||
if (j_.debug)
|
||||
{
|
||||
JLOG (j_.debug)
|
||||
j_.debug
|
||||
<< "rippleCalc: Summary:"
|
||||
<< " Pass: " << iPass
|
||||
<< " Dry: " << iDry
|
||||
<< " Paths: " << pathStateList_.size ();
|
||||
for (auto pathState: pathStateList_)
|
||||
{
|
||||
JLOG (j_.debug)
|
||||
j_.debug
|
||||
<< "rippleCalc: "
|
||||
<< "Summary: " << pathState->index()
|
||||
<< " rate: "
|
||||
|
||||
@@ -338,10 +338,13 @@ TER PathCursor::deliverNodeForward (
|
||||
}
|
||||
else
|
||||
{
|
||||
CondLog (saOutPassAct >= saOutFunded, lsWARNING, RippleCalc)
|
||||
if (saOutPassAct >= saOutFunded)
|
||||
{
|
||||
JLOG (j_.warning)
|
||||
<< "deliverNodeForward: TOO MUCH:"
|
||||
<< " saOutPassAct=" << saOutPassAct
|
||||
<< " saOutFunded=" << saOutFunded;
|
||||
}
|
||||
|
||||
assert (saOutPassAct < saOutFunded);
|
||||
}
|
||||
|
||||
@@ -337,10 +337,13 @@ TER PathCursor::deliverNodeReverseImpl (
|
||||
previousNode().saRevDeliver += saInPassAct;
|
||||
}
|
||||
|
||||
CondLog (saOutAct > saOutReq, lsWARNING, RippleCalc)
|
||||
if (saOutAct > saOutReq)
|
||||
{
|
||||
JLOG (j_.warning)
|
||||
<< "deliverNodeReverse: TOO MUCH:"
|
||||
<< " saOutAct=" << saOutAct
|
||||
<< " saOutReq=" << saOutReq;
|
||||
}
|
||||
|
||||
assert(saOutAct <= saOutReq);
|
||||
|
||||
|
||||
@@ -39,31 +39,23 @@ void PathCursor::nextIncrement () const
|
||||
{
|
||||
// The next state is what is available in preference order.
|
||||
// This is calculated when referenced accounts changed.
|
||||
// VFALCO-FIXME this generates errors
|
||||
// JLOG (j_.trace)
|
||||
// << "nextIncrement: Path In: " << pathState_.getJson ();
|
||||
|
||||
auto status = liquidity();
|
||||
|
||||
if (status == tesSUCCESS)
|
||||
{
|
||||
auto isDry = pathState_.isDry();
|
||||
CondLog (isDry, lsDEBUG, RippleCalc)
|
||||
<< "nextIncrement: Error forwardLiquidity reported success"
|
||||
<< " on dry path:"
|
||||
<< " saOutPass=" << pathState_.outPass()
|
||||
<< " inPass()=" << pathState_.inPass();
|
||||
|
||||
if (isDry)
|
||||
if (pathState_.isDry())
|
||||
{
|
||||
JLOG (j_.debug)
|
||||
<< "nextIncrement: success on dry path:"
|
||||
<< " outPass=" << pathState_.outPass()
|
||||
<< " inPass=" << pathState_.inPass();
|
||||
Throw<std::runtime_error> ("Made no progress.");
|
||||
}
|
||||
|
||||
// Calculate relative quality.
|
||||
pathState_.setQuality(getRate (
|
||||
pathState_.outPass(), pathState_.inPass()));
|
||||
|
||||
// VFALCO-FIXME this generates errors
|
||||
// JLOG (j_.trace)
|
||||
// << "nextIncrement: Path after forward: " << pathState_.getJson ();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -236,6 +236,22 @@ private:
|
||||
#define JLOG(x) if (!x) { } else x
|
||||
#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
|
||||
inline
|
||||
@@ -265,25 +281,6 @@ private:
|
||||
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
|
||||
|
||||
#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
|
||||
|
||||
@@ -52,10 +52,12 @@ T rangeCheckedCast (C c)
|
||||
std::numeric_limits<C>::is_signed &&
|
||||
c < std::numeric_limits<T>::lowest ()))
|
||||
{
|
||||
WriteLog (lsERROR, RangeCheckedCast)
|
||||
<< "Range error. Min: " << std::numeric_limits<T>::lowest ()
|
||||
<< " Max: " << std::numeric_limits<T>::max () << " Got: " << c;
|
||||
JLOG (debugJournal().error) << "rangeCheckedCast domain error:"
|
||||
<< " value = " << c
|
||||
<< " min = " << std::numeric_limits<T>::lowest ()
|
||||
<< " max: " << std::numeric_limits<T>::max ();
|
||||
}
|
||||
|
||||
return static_cast<T>(c);
|
||||
}
|
||||
|
||||
|
||||
@@ -1435,7 +1435,7 @@ accountSend (ApplyView& view,
|
||||
? view.peek (keylet::account(uReceiverID))
|
||||
: SLE::pointer ();
|
||||
|
||||
if (ShouldLog (lsTRACE, View))
|
||||
if (j.trace)
|
||||
{
|
||||
std::string sender_bal ("-");
|
||||
std::string receiver_bal ("-");
|
||||
@@ -1446,7 +1446,7 @@ accountSend (ApplyView& view,
|
||||
if (receiver)
|
||||
receiver_bal = receiver->getFieldAmount (sfBalance).getFullText ();
|
||||
|
||||
JLOG (j.trace) << "accountSend> " <<
|
||||
j.trace << "accountSend> " <<
|
||||
to_string (uSenderID) << " (" << sender_bal <<
|
||||
") -> " << to_string (uReceiverID) << " (" << receiver_bal <<
|
||||
") : " << saAmount.getFullText ();
|
||||
@@ -1479,7 +1479,7 @@ accountSend (ApplyView& view,
|
||||
view.update (receiver);
|
||||
}
|
||||
|
||||
if (ShouldLog (lsTRACE, View))
|
||||
if (j.trace)
|
||||
{
|
||||
std::string sender_bal ("-");
|
||||
std::string receiver_bal ("-");
|
||||
@@ -1490,7 +1490,7 @@ accountSend (ApplyView& view,
|
||||
if (receiver)
|
||||
receiver_bal = receiver->getFieldAmount (sfBalance).getFullText ();
|
||||
|
||||
JLOG (j.trace) << "accountSend< " <<
|
||||
j.trace << "accountSend< " <<
|
||||
to_string (uSenderID) << " (" << sender_bal <<
|
||||
") -> " << to_string (uReceiverID) << " (" << receiver_bal <<
|
||||
") : " << saAmount.getFullText ();
|
||||
|
||||
@@ -893,10 +893,10 @@ public:
|
||||
// <-- { method: xyz, params: [... ] } or { error: ..., ... }
|
||||
Json::Value parseCommand (std::string strMethod, Json::Value jvParams, bool allowAnyCommand)
|
||||
{
|
||||
if (ShouldLog (lsTRACE, RPCParser))
|
||||
if (j_.trace)
|
||||
{
|
||||
JLOG (j_.trace) << "RPC method:" << strMethod;
|
||||
JLOG (j_.trace) << "RPC params:" << jvParams;
|
||||
j_.trace << "Method: '" << strMethod << "'";
|
||||
j_.trace << "Params: " << jvParams;
|
||||
}
|
||||
|
||||
struct Command
|
||||
|
||||
@@ -151,7 +151,6 @@ public:
|
||||
bool getVL (Blob& objectVL, int offset, int& length) 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 (SerializedTypeID type, int name)
|
||||
{
|
||||
|
||||
@@ -812,12 +812,6 @@ amountFromJson (SField const& name, Json::Value const& v)
|
||||
|
||||
if (v.isObject ())
|
||||
{
|
||||
WriteLog (lsTRACE, STAmount) <<
|
||||
"value='" << v[jss::value].asString () <<
|
||||
"', currency='" << v["currency"].asString () <<
|
||||
"', issuer='" << v["issuer"].asString () <<
|
||||
"')";
|
||||
|
||||
value = v[jss::value];
|
||||
currency = v[jss::currency];
|
||||
issuer = v[jss::issuer];
|
||||
@@ -916,7 +910,7 @@ amountFromJsonNoThrow (STAmount& result, Json::Value const& jvSource)
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
WriteLog (lsDEBUG, STAmount) <<
|
||||
JLOG (debugJournal().debug) <<
|
||||
"amountFromJsonNoThrow: caught: " << e.what ();
|
||||
}
|
||||
return false;
|
||||
@@ -1104,9 +1098,6 @@ canonicalizeRound (bool native, std::uint64_t& value, int& offset, bool roundUp)
|
||||
if (!roundUp) // canonicalize already rounds down
|
||||
return;
|
||||
|
||||
WriteLog (lsTRACE, STAmount)
|
||||
<< "canonicalizeRound< " << value << ":" << offset;
|
||||
|
||||
if (native)
|
||||
{
|
||||
if (offset < 0)
|
||||
@@ -1137,9 +1128,6 @@ canonicalizeRound (bool native, std::uint64_t& value, int& offset, bool roundUp)
|
||||
value /= 10;
|
||||
++offset;
|
||||
}
|
||||
|
||||
WriteLog (lsTRACE, STAmount)
|
||||
<< "canonicalizeRound> " << value << ":" << offset;
|
||||
}
|
||||
|
||||
STAmount
|
||||
|
||||
@@ -76,7 +76,7 @@ STArray::STArray (SerialIter& sit, SField const& f)
|
||||
|
||||
if ((type == STI_OBJECT) && (field == 1))
|
||||
{
|
||||
WriteLog (lsWARNING, STObject) <<
|
||||
JLOG (debugJournal().warning) <<
|
||||
"Encountered array with end of object marker";
|
||||
Throw<std::runtime_error> ("Illegal terminator in array");
|
||||
}
|
||||
@@ -85,14 +85,15 @@ STArray::STArray (SerialIter& sit, SField const& f)
|
||||
|
||||
if (fn.isInvalid ())
|
||||
{
|
||||
WriteLog (lsTRACE, STObject) <<
|
||||
JLOG (debugJournal().trace) <<
|
||||
"Unknown field: " << type << "/" << field;
|
||||
Throw<std::runtime_error> ("Unknown field");
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
@@ -172,16 +173,8 @@ void STArray::add (Serializer& s) const
|
||||
|
||||
bool STArray::isEquivalent (const STBase& t) const
|
||||
{
|
||||
const STArray* v = dynamic_cast<const STArray*> (&t);
|
||||
|
||||
if (!v)
|
||||
{
|
||||
WriteLog (lsDEBUG, STObject) <<
|
||||
"notEquiv " << getFullText() << " not array";
|
||||
return false;
|
||||
}
|
||||
|
||||
return v_ == v->v_;
|
||||
auto v = dynamic_cast<const STArray*> (&t);
|
||||
return v != nullptr && v_ == v->v_;
|
||||
}
|
||||
|
||||
void STArray::sort (bool (*compare) (const STObject&, const STObject&))
|
||||
|
||||
@@ -51,6 +51,9 @@ STUInt8::getText () const
|
||||
|
||||
if (transResultInfo (static_cast<TER> (value_), token, human))
|
||||
return human;
|
||||
|
||||
JLOG (debugJournal().warning)
|
||||
<< "Unknown result code in metadata: " << value_;
|
||||
}
|
||||
|
||||
return beast::lexicalCastThrow <std::string> (value_);
|
||||
@@ -66,8 +69,8 @@ STUInt8::getJson (int) const
|
||||
|
||||
if (transResultInfo (static_cast<TER> (value_), token, human))
|
||||
return token;
|
||||
else
|
||||
WriteLog (lsWARNING, STBase)
|
||||
|
||||
JLOG (debugJournal().warning)
|
||||
<< "Unknown result code in metadata: " << value_;
|
||||
}
|
||||
|
||||
|
||||
@@ -78,9 +78,12 @@ void STLedgerEntry::setSLEType ()
|
||||
type_ = mFormat->getType ();
|
||||
if (!setType (mFormat->elements))
|
||||
{
|
||||
WriteLog (lsWARNING, SerializedLedger)
|
||||
<< "Ledger entry not valid for type " << mFormat->getName ();
|
||||
WriteLog (lsWARNING, SerializedLedger) << getJson (0);
|
||||
if (auto j = debugJournal().warning)
|
||||
{
|
||||
j << "Ledger entry not valid for type " << mFormat->getName ();
|
||||
j << "Object: " << getJson (0);
|
||||
}
|
||||
|
||||
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 oldPrevTxID = getFieldH256 (sfPreviousTxnID);
|
||||
WriteLog (lsTRACE, SerializedLedger) << "Thread Tx:" << txID << " prev:" << oldPrevTxID;
|
||||
|
||||
JLOG (debugJournal().trace)
|
||||
<< "Thread Tx:" << txID << " prev:" << oldPrevTxID;
|
||||
|
||||
if (oldPrevTxID == txID)
|
||||
{
|
||||
|
||||
@@ -113,9 +113,9 @@ bool STObject::setType (const SOTemplate& type)
|
||||
{
|
||||
if ((e->flags == SOE_DEFAULT) && iter->get().isDefault())
|
||||
{
|
||||
WriteLog (lsWARNING, STObject) <<
|
||||
"setType( " << getFName ().getName () <<
|
||||
" ) invalid default " << e->e_field.fieldName;
|
||||
JLOG (debugJournal().warning)
|
||||
<< "setType(" << getFName().getName()
|
||||
<< "): explicit default " << e->e_field.fieldName;
|
||||
valid = false;
|
||||
}
|
||||
v.emplace_back(std::move(*iter));
|
||||
@@ -125,9 +125,9 @@ bool STObject::setType (const SOTemplate& type)
|
||||
{
|
||||
if (e->flags == SOE_REQUIRED)
|
||||
{
|
||||
WriteLog (lsWARNING, STObject) <<
|
||||
"setType( " << getFName ().getName () <<
|
||||
" ) invalid missing " << e->e_field.fieldName;
|
||||
JLOG (debugJournal().warning)
|
||||
<< "setType(" << getFName().getName()
|
||||
<< "): missing " << e->e_field.fieldName;
|
||||
valid = false;
|
||||
}
|
||||
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
|
||||
if (! e->getFName().isDiscardable())
|
||||
{
|
||||
WriteLog (lsWARNING, STObject) <<
|
||||
"setType( " << getFName ().getName () <<
|
||||
" ) invalid leftover " << e->getFName ().getName ();
|
||||
JLOG (debugJournal().warning)
|
||||
<< "setType(" << getFName().getName()
|
||||
<< "): non-discardable leftover " << e->getFName().getName ();
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
@@ -208,8 +208,8 @@ bool STObject::set (SerialIter& sit, int depth)
|
||||
|
||||
if ((type == STI_ARRAY) && (field == 1))
|
||||
{
|
||||
WriteLog (lsWARNING, STObject) <<
|
||||
"Encountered object with end of array marker";
|
||||
JLOG (debugJournal().warning)
|
||||
<< "Encountered object with end of array marker";
|
||||
Throw<std::runtime_error> ("Illegal terminator in object");
|
||||
}
|
||||
|
||||
@@ -221,9 +221,9 @@ bool STObject::set (SerialIter& sit, int depth)
|
||||
|
||||
if (fn.isInvalid ())
|
||||
{
|
||||
WriteLog (lsWARNING, STObject) <<
|
||||
"Unknown field: field_type=" << type <<
|
||||
", field_name=" << field;
|
||||
JLOG (debugJournal().warning)
|
||||
<< "Unknown field: field_type=" << type
|
||||
<< ", field_name=" << 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);
|
||||
|
||||
if (!v)
|
||||
{
|
||||
WriteLog (lsDEBUG, STObject) <<
|
||||
"notEquiv " << getFullText() << " not object";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mType != nullptr && (v->mType == mType))
|
||||
return equivalentSTObjectSameTemplate (*this, *v);
|
||||
@@ -727,14 +723,9 @@ bool STObject::operator== (const STObject& obj) const
|
||||
}
|
||||
|
||||
if (!match)
|
||||
{
|
||||
WriteLog (lsTRACE, STObject) <<
|
||||
"STObject::operator==: no match for " <<
|
||||
t1->getFName ().getName ();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int fields = 0;
|
||||
for (auto const& t2 : obj.v_)
|
||||
@@ -744,11 +735,7 @@ bool STObject::operator== (const STObject& obj) const
|
||||
}
|
||||
|
||||
if (fields != matches)
|
||||
{
|
||||
WriteLog (lsTRACE, STObject) << "STObject::operator==: " <<
|
||||
fields << " fields, " << matches << " matches";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -64,8 +64,8 @@ STPathSet::STPathSet (SerialIter& sit, SField const& name)
|
||||
{
|
||||
if (path.empty ())
|
||||
{
|
||||
WriteLog (lsINFO, STBase)
|
||||
<< "STPathSet: Empty path.";
|
||||
JLOG (debugJournal().info)
|
||||
<< "Empty path in pathset";
|
||||
Throw<std::runtime_error> ("empty path");
|
||||
}
|
||||
|
||||
@@ -77,9 +77,8 @@ STPathSet::STPathSet (SerialIter& sit, SField const& name)
|
||||
}
|
||||
else if (iType & ~STPathElement::typeAll)
|
||||
{
|
||||
WriteLog (lsINFO, STBase)
|
||||
<< "STPathSet: Bad path element: " << iType;
|
||||
|
||||
JLOG (debugJournal().info)
|
||||
<< "Bad path element " << iType << " in pathset";
|
||||
Throw<std::runtime_error> ("bad path element");
|
||||
}
|
||||
else
|
||||
|
||||
@@ -35,7 +35,8 @@ STValidation::STValidation (SerialIter& sit, bool checkSignature)
|
||||
|
||||
if (checkSignature && !isValid ())
|
||||
{
|
||||
WriteLog (lsTRACE, Ledger) << "Invalid validation " << getJson (0);
|
||||
JLOG (debugJournal().trace)
|
||||
<< "Invalid validation" << getJson (0);
|
||||
Throw<std::runtime_error> ("Invalid validation");
|
||||
}
|
||||
}
|
||||
@@ -112,7 +113,8 @@ bool STValidation::isValid (uint256 const& signingHash) const
|
||||
}
|
||||
catch (std::exception const&)
|
||||
{
|
||||
WriteLog (lsINFO, Ledger) << "exception validating validation";
|
||||
JLOG (debugJournal().info)
|
||||
<< "Exception validating validation";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,46 +148,6 @@ int Serializer::addFieldID (int type, int name)
|
||||
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 ret = mData.size ();
|
||||
|
||||
@@ -26,30 +26,33 @@ namespace log {
|
||||
void websocketLog (
|
||||
websocketpp_02::log::alevel::value v, std::string const& entry)
|
||||
{
|
||||
using namespace ripple;
|
||||
auto isTrace = v == websocketpp_02::log::alevel::DEVEL ||
|
||||
auto const isTrace =
|
||||
v == websocketpp_02::log::alevel::DEVEL ||
|
||||
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 (
|
||||
websocketpp_02::log::elevel::value v, std::string const& entry)
|
||||
{
|
||||
using namespace ripple;
|
||||
|
||||
LogSeverity s = lsDEBUG;
|
||||
auto journal = ripple::debugJournal();
|
||||
|
||||
if ((v & websocketpp_02::log::elevel::INFO) != 0)
|
||||
s = lsINFO;
|
||||
JLOG (journal.info) << entry;
|
||||
else if ((v & websocketpp_02::log::elevel::FATAL) != 0)
|
||||
s = lsFATAL;
|
||||
JLOG (journal.fatal) << entry;
|
||||
else if ((v & websocketpp_02::log::elevel::RERROR) != 0)
|
||||
s = lsERROR;
|
||||
JLOG (journal.error) << entry;
|
||||
else if ((v & websocketpp_02::log::elevel::WARN) != 0)
|
||||
s = lsWARNING;
|
||||
|
||||
WriteLog(s, WebSocket) << entry;
|
||||
JLOG (journal.warning) << entry;
|
||||
else
|
||||
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