Log detailed correlated consensus data together (#5302)

Combine multiple related debug log data points into a single
message. Allows quick correlation of events that
previously were either not logged or, if logged, strewn
across multiple lines, making correlation difficult.
The Heartbeat Timer and consensus ledger accept processing
each have this capability.

Also guarantees that log entries will be written if the
node is a validator, regardless of log severity level.
Otherwise, the level of these messages is at INFO severity.
This commit is contained in:
Mark Travis
2025-02-27 10:02:57 -08:00
committed by GitHub
parent 0a1ca0600f
commit af018c7b0b
20 changed files with 546 additions and 134 deletions

View File

@@ -116,6 +116,10 @@ struct Peer
}
};
class TestConsensusLogger
{
};
/** Generic Validations adaptor that simply ignores recently stale
* validations
*/
@@ -532,7 +536,8 @@ struct Peer
closeResolution,
rawCloseTimes,
mode,
std::move(consensusJson));
std::move(consensusJson),
validating());
}
void
@@ -542,7 +547,8 @@ struct Peer
NetClock::duration const& closeResolution,
ConsensusCloseTimes const& rawCloseTimes,
ConsensusMode const& mode,
Json::Value&& consensusJson)
Json::Value&& consensusJson,
const bool validating)
{
schedule(delays.ledgerAccept, [=, this]() {
const bool proposing = mode == ConsensusMode::proposing;
@@ -877,6 +883,13 @@ struct Peer
{
}
bool
validating() const
{
// does not matter
return false;
}
//--------------------------------------------------------------------------
// A locally submitted transaction
void
@@ -917,7 +930,7 @@ struct Peer
// Not yet modeling dynamic UNL.
hash_set<PeerID> nowUntrusted;
consensus.startRound(
now(), bestLCL, lastClosedLedger, nowUntrusted, runAsValidator);
now(), bestLCL, lastClosedLedger, nowUntrusted, runAsValidator, {});
}
// Start the consensus process assuming it is not yet running

View File

@@ -57,6 +57,14 @@ public:
std::cout << clock_.now().time_since_epoch().count() << " " << text
<< std::endl;
}
void
writeAlways(beast::severities::Severity level, std::string const& text)
override
{
std::cout << clock_.now().time_since_epoch().count() << " " << text
<< std::endl;
}
};
class Sim