mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge #12891: [logging] add lint-logs.sh to check for newline termination.
d207207
[logging] add lint-logs.sh to check for newline termination. (John Newbery)5c21e6c
[logging] Comment all continuing logs. (John Newbery) Pull request description: Check that all calls to LogPrintf() are terminated by a newline, except those that are explicitly marked as 'continued' logs. Tree-SHA512: fe5162b2b2df1e8a4c807da87584fa9af97a6b8377e4090fe0caa136d90bf29a487a123cde94569bdce7101fee3478196d99aa13f1212e24bfe5f41c773604fc
This commit is contained in:
parent
9b9005e395
commit
101f73bb6d
25
contrib/devtools/lint-logs.sh
Executable file
25
contrib/devtools/lint-logs.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2018 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
#
|
||||
# Check that all logs are terminated with '\n'
|
||||
#
|
||||
# Some logs are continued over multiple lines. They should be explicitly
|
||||
# commented with \* Continued *\
|
||||
#
|
||||
# There are some instances of LogPrintf() in comments. Those can be
|
||||
# ignored
|
||||
|
||||
|
||||
UNTERMINATED_LOGS=$(git grep "LogPrintf(" -- "*.cpp" | \
|
||||
grep -v '\\n"' | \
|
||||
grep -v "/\* Continued \*/" | \
|
||||
grep -v "LogPrintf()")
|
||||
if [[ ${UNTERMINATED_LOGS} != "" ]]; then
|
||||
echo "All calls to LogPrintf() should be terminated with \\n"
|
||||
echo
|
||||
echo "${UNTERMINATED_LOGS}"
|
||||
exit 1
|
||||
fi
|
@ -63,7 +63,7 @@ public:
|
||||
|
||||
assert(p <= limit);
|
||||
base[std::min(bufsize - 1, (int)(p - base))] = '\0';
|
||||
LogPrintf("leveldb: %s", base);
|
||||
LogPrintf("leveldb: %s", base); /* Continued */
|
||||
if (base != buffer) {
|
||||
delete[] base;
|
||||
}
|
||||
|
@ -1565,7 +1565,7 @@ bool AppInitMain()
|
||||
|
||||
// Warn about relative -datadir path.
|
||||
if (gArgs.IsArgSet("-datadir") && !fs::path(gArgs.GetArg("-datadir", "")).is_absolute()) {
|
||||
LogPrintf("Warning: relative datadir option '%s' specified, which will be interpreted relative to the "
|
||||
LogPrintf("Warning: relative datadir option '%s' specified, which will be interpreted relative to the " /* Continued */
|
||||
"current working directory '%s'. This is fragile, because if Dash Core is started in the future "
|
||||
"from a different location, it will be unable to locate the current data files. There could "
|
||||
"also be data loss if Dash Core is started while in a temporary directory.\n",
|
||||
|
@ -81,20 +81,20 @@ static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch,
|
||||
strOutput += "Previous lock order was:\n";
|
||||
for (const std::pair<void*, CLockLocation> & i : s2) {
|
||||
if (i.first == mismatch.first) {
|
||||
strOutput += " (1)";
|
||||
strOutput += " (1)"; /* Continued */
|
||||
}
|
||||
if (i.first == mismatch.second) {
|
||||
strOutput += " (2)";
|
||||
strOutput += " (2)"; /* Continued */
|
||||
}
|
||||
strOutput += strprintf(" %s\n", i.second.ToString().c_str());
|
||||
}
|
||||
strOutput += "Current lock order is:\n";
|
||||
for (const std::pair<void*, CLockLocation> & i : s1) {
|
||||
if (i.first == mismatch.first) {
|
||||
strOutput += " (1)";
|
||||
strOutput += " (1)"; /* Continued */
|
||||
}
|
||||
if (i.first == mismatch.second) {
|
||||
strOutput += " (2)";
|
||||
strOutput += " (2)"; /* Continued */
|
||||
}
|
||||
strOutput += strprintf(" %s\n", i.second.ToString().c_str());
|
||||
}
|
||||
|
@ -524,7 +524,7 @@ bool CCoinsViewDB::Upgrade() {
|
||||
|
||||
int64_t count = 0;
|
||||
LogPrintf("Upgrading utxo-set database...\n");
|
||||
LogPrintf("[0%%]...");
|
||||
LogPrintf("[0%%]..."); /* Continued */
|
||||
uiInterface.ShowProgress(_("Upgrading UTXO database"), 0, true);
|
||||
size_t batch_size = 1 << 24;
|
||||
CDBBatch batch(db);
|
||||
@ -543,7 +543,7 @@ bool CCoinsViewDB::Upgrade() {
|
||||
uiInterface.ShowProgress(_("Upgrading UTXO database"), percentageDone, true);
|
||||
if (reportDone < percentageDone/10) {
|
||||
// report max. every 10% step
|
||||
LogPrintf("[%d%%]...", percentageDone);
|
||||
LogPrintf("[%d%%]...", percentageDone); /* Continued */
|
||||
reportDone = percentageDone/10;
|
||||
}
|
||||
}
|
||||
|
@ -2548,14 +2548,14 @@ void static UpdateTip(const CBlockIndex *pindexNew, const CChainParams& chainPar
|
||||
DoWarning(strWarning);
|
||||
}
|
||||
}
|
||||
std::string strMessage = strprintf("%s: new best=%s height=%d version=0x%08x log2_work=%.8f tx=%lu date='%s' progress=%f cache=%.1fMiB(%utxo)", __func__,
|
||||
std::string strMessage = strprintf("%s: new best=%s height=%d version=0x%08x log2_work=%.8f tx=%lu date='%s' progress=%f cache=%.1fMiB(%utxo)", __func__, /* Continued */
|
||||
pindexNew->GetBlockHash().ToString(), pindexNew->nHeight, pindexNew->nVersion,
|
||||
log(pindexNew->nChainWork.getdouble())/log(2.0), (unsigned long)pindexNew->nChainTx,
|
||||
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", pindexNew->GetBlockTime()),
|
||||
GuessVerificationProgress(chainParams.TxData(), pindexNew), pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize());
|
||||
strMessage += strprintf(" evodb_cache=%.1fMiB", evoDb->GetMemoryUsage() * (1.0 / (1<<20)));
|
||||
if (!warningMessages.empty())
|
||||
strMessage += strprintf(" warning='%s'", boost::algorithm::join(warningMessages, ", "));
|
||||
strMessage += strprintf(" warning='%s'", boost::algorithm::join(warningMessages, ", ")); /* Continued */
|
||||
LogPrintf("%s\n", strMessage);
|
||||
}
|
||||
|
||||
@ -4227,14 +4227,14 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview,
|
||||
int nGoodTransactions = 0;
|
||||
CValidationState state;
|
||||
int reportDone = 0;
|
||||
LogPrintf("[0%%]...");
|
||||
LogPrintf("[0%%]..."); /* Continued */
|
||||
for (CBlockIndex* pindex = chainActive.Tip(); pindex && pindex->pprev; pindex = pindex->pprev)
|
||||
{
|
||||
boost::this_thread::interruption_point();
|
||||
int percentageDone = std::max(1, std::min(99, (int)(((double)(chainActive.Height() - pindex->nHeight)) / (double)nCheckDepth * (nCheckLevel >= 4 ? 50 : 100))));
|
||||
if (reportDone < percentageDone/10) {
|
||||
// report every 10% step
|
||||
LogPrintf("[%d%%]...", percentageDone);
|
||||
LogPrintf("[%d%%]...", percentageDone); /* Continued */
|
||||
reportDone = percentageDone/10;
|
||||
}
|
||||
uiInterface.ShowProgress(_("Verifying blocks..."), percentageDone, false);
|
||||
|
@ -4065,7 +4065,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, CCon
|
||||
{
|
||||
LOCK2(cs_main, mempool.cs);
|
||||
LOCK(cs_wallet);
|
||||
LogPrintf("CommitTransaction:\n%s", wtxNew.tx->ToString());
|
||||
LogPrintf("CommitTransaction:\n%s", wtxNew.tx->ToString()); /* Continued */
|
||||
{
|
||||
// Take key pair from key pool so it won't be used again
|
||||
reservekey.KeepKey();
|
||||
|
Loading…
Reference in New Issue
Block a user