mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 05:55:51 +00:00
New implementation to replace logging macros
This commit is contained in:
@@ -7,8 +7,6 @@
|
||||
#include "ValidationCollection.h"
|
||||
#include "HashPrefixes.h"
|
||||
|
||||
SETUP_LOG();
|
||||
|
||||
void FeatureTable::addInitialFeatures()
|
||||
{
|
||||
// For each feature this version supports, call enableFeature.
|
||||
@@ -175,13 +173,13 @@ void FeatureTable::reportValidations(const FeatureSet& set)
|
||||
BOOST_FOREACH(const u256_int_pair& it, set.mVotes)
|
||||
{
|
||||
FeatureState& state = mFeatureMap[it.first];
|
||||
cLog(lsDEBUG) << "Feature " << it.first.GetHex() << " has " << it.second << " votes, needs " << threshold;
|
||||
WriteLog (lsDEBUG, FeatureTable) << "Feature " << it.first.GetHex() << " has " << it.second << " votes, needs " << threshold;
|
||||
if (it.second >= threshold)
|
||||
{ // we have a majority
|
||||
state.mLastMajority = set.mCloseTime;
|
||||
if (state.mFirstMajority == 0)
|
||||
{
|
||||
cLog(lsWARNING) << "Feature " << it.first << " attains a majority vote";
|
||||
WriteLog (lsWARNING, FeatureTable) << "Feature " << it.first << " attains a majority vote";
|
||||
state.mFirstMajority = set.mCloseTime;
|
||||
changedFeatures.push_back(it.first);
|
||||
}
|
||||
@@ -190,7 +188,7 @@ void FeatureTable::reportValidations(const FeatureSet& set)
|
||||
{
|
||||
if (state.mFirstMajority != 0)
|
||||
{
|
||||
cLog(lsWARNING) << "Feature " << it.first << " loses majority vote";
|
||||
WriteLog (lsWARNING, FeatureTable) << "Feature " << it.first << " loses majority vote";
|
||||
state.mFirstMajority = 0;
|
||||
state.mLastMajority = 0;
|
||||
changedFeatures.push_back(it.first);
|
||||
@@ -254,12 +252,12 @@ void FeatureTable::doVoting(Ledger::ref lastClosedLedger, SHAMap::ref initialPos
|
||||
|
||||
BOOST_FOREACH(const uint256& uFeature, lFeatures)
|
||||
{
|
||||
cLog(lsWARNING) << "We are voting for feature " << uFeature;
|
||||
WriteLog (lsWARNING, FeatureTable) << "We are voting for feature " << uFeature;
|
||||
SerializedTransaction trans(ttFEATURE);
|
||||
trans.setFieldAccount(sfAccount, uint160());
|
||||
trans.setFieldH256(sfFeature, uFeature);
|
||||
uint256 txID = trans.getTransactionID();
|
||||
cLog(lsWARNING) << "Vote: " << txID;
|
||||
WriteLog (lsWARNING, FeatureTable) << "Vote: " << txID;
|
||||
|
||||
Serializer s;
|
||||
trans.add(s, true);
|
||||
@@ -267,7 +265,7 @@ void FeatureTable::doVoting(Ledger::ref lastClosedLedger, SHAMap::ref initialPos
|
||||
SHAMapItem::pointer tItem = boost::make_shared<SHAMapItem>(txID, s.peekData());
|
||||
if (!initialPosition->addGiveItem(tItem, true, false))
|
||||
{
|
||||
cLog(lsWARNING) << "Ledger already had feature transaction";
|
||||
WriteLog (lsWARNING, FeatureTable) << "Ledger already had feature transaction";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -375,19 +373,19 @@ void FeeVote::doValidation(Ledger::ref lastClosedLedger, STObject& validation)
|
||||
{
|
||||
if (lastClosedLedger->getBaseFee() != mTargetBaseFee)
|
||||
{
|
||||
cLog(lsINFO) << "Voting for base fee of " << mTargetBaseFee;
|
||||
WriteLog (lsINFO, FeatureTable) << "Voting for base fee of " << mTargetBaseFee;
|
||||
validation.setFieldU64(sfBaseFee, mTargetBaseFee);
|
||||
}
|
||||
|
||||
if (lastClosedLedger->getReserve(0) != mTargetReserveBase)
|
||||
{
|
||||
cLog(lsINFO) << "Voting for base resrve of " << mTargetReserveBase;
|
||||
WriteLog (lsINFO, FeatureTable) << "Voting for base resrve of " << mTargetReserveBase;
|
||||
validation.setFieldU32(sfReserveBase, mTargetReserveBase);
|
||||
}
|
||||
|
||||
if (lastClosedLedger->getReserveInc() != mTargetReserveIncrement)
|
||||
{
|
||||
cLog(lsINFO) << "Voting for reserve increment of " << mTargetReserveIncrement;
|
||||
WriteLog (lsINFO, FeatureTable) << "Voting for reserve increment of " << mTargetReserveIncrement;
|
||||
validation.setFieldU32(sfReserveIncrement, mTargetReserveIncrement);
|
||||
}
|
||||
}
|
||||
@@ -433,7 +431,7 @@ void FeeVote::doVoting(Ledger::ref lastClosedLedger, SHAMap::ref initialPosition
|
||||
(baseReserve != lastClosedLedger->getReserve(0)) ||
|
||||
(incReserve != lastClosedLedger->getReserveInc()))
|
||||
{
|
||||
cLog(lsWARNING) << "We are voting for a fee change: " << baseFee << "/" << baseReserve << "/" << incReserve;
|
||||
WriteLog (lsWARNING, FeatureTable) << "We are voting for a fee change: " << baseFee << "/" << baseReserve << "/" << incReserve;
|
||||
SerializedTransaction trans(ttFEE);
|
||||
trans.setFieldAccount(sfAccount, uint160());
|
||||
trans.setFieldU64(sfBaseFee, baseFee);
|
||||
@@ -441,7 +439,7 @@ void FeeVote::doVoting(Ledger::ref lastClosedLedger, SHAMap::ref initialPosition
|
||||
trans.setFieldU32(sfReserveBase, baseReserve);
|
||||
trans.setFieldU32(sfReserveIncrement, incReserve);
|
||||
uint256 txID = trans.getTransactionID();
|
||||
cLog(lsWARNING) << "Vote: " << txID;
|
||||
WriteLog (lsWARNING, FeatureTable) << "Vote: " << txID;
|
||||
|
||||
Serializer s;
|
||||
trans.add(s, true);
|
||||
@@ -449,7 +447,7 @@ void FeeVote::doVoting(Ledger::ref lastClosedLedger, SHAMap::ref initialPosition
|
||||
SHAMapItem::pointer tItem = boost::make_shared<SHAMapItem>(txID, s.peekData());
|
||||
if (!initialPosition->addGiveItem(tItem, true, false))
|
||||
{
|
||||
cLog(lsWARNING) << "Ledger already had fee change";
|
||||
WriteLog (lsWARNING, FeatureTable) << "Ledger already had fee change";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ protected:
|
||||
public:
|
||||
LogPartition(const char *name);
|
||||
|
||||
bool doLog(LogSeverity s) { return s >= mMinSeverity; }
|
||||
bool doLog(LogSeverity s) const { return s >= mMinSeverity; }
|
||||
const std::string& getName() const { return mName; }
|
||||
|
||||
static bool setSeverity(const std::string& partition, LogSeverity severity);
|
||||
@@ -110,6 +110,23 @@ public:
|
||||
static std::string rotateLog(void);
|
||||
};
|
||||
|
||||
//-----
|
||||
|
||||
template <class Key>
|
||||
inline LogPartition const& getLogPartition ()
|
||||
{
|
||||
static LogPartition logPartition (__FILE__);
|
||||
return logPartition;
|
||||
}
|
||||
|
||||
template <class Key>
|
||||
inline Log getLog (LogSeverity level)
|
||||
{
|
||||
return Log (level, getLogPartition <Key> ());
|
||||
}
|
||||
|
||||
#define WriteLog(s, k) if (!getLogPartition <k> ().doLog (s)) do {} while (0); else Log (s, getLogPartition <k> ())
|
||||
|
||||
#endif
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
Reference in New Issue
Block a user