Skip to content

Commit ef46c99

Browse files
committed
Merge #13153: Add missing newlines to debug logging
4b75dcf devtools: Make linter check LogPrint calls (MarcoFalke) ff2ad2d Add missing newlines to LogPrint debug logging (Wladimir J. van der Laan) Pull request description: ~~Don't we have a linter that should catch these?~~ Tree-SHA512: 1a58eca01ded9c1719e943c09447deeb59bb06dba00528cf460eefe857fdf95b42671fbdebc87cdd2f51e931e86942d06587ffd097cbb0d8dd9eb7a0ba17a8f0
2 parents 598db38 + 4b75dcf commit ef46c99

File tree

6 files changed

+11
-10
lines changed

6 files changed

+11
-10
lines changed

contrib/devtools/lint-logs.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
# ignored
1414

1515

16-
UNTERMINATED_LOGS=$(git grep "LogPrintf(" -- "*.cpp" | \
16+
UNTERMINATED_LOGS=$(git grep --extended-regexp "LogPrintf?\(" -- "*.cpp" | \
1717
grep -v '\\n"' | \
1818
grep -v "/\* Continued \*/" | \
19+
grep -v "LogPrint()" | \
1920
grep -v "LogPrintf()")
2021
if [[ ${UNTERMINATED_LOGS} != "" ]]; then
21-
echo "All calls to LogPrintf() should be terminated with \\n"
22+
echo "All calls to LogPrintf() and LogPrint() should be terminated with \\n"
2223
echo
2324
echo "${UNTERMINATED_LOGS}"
2425
exit 1

src/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
395395
if (Lookup(pszDest, resolved, default_port, fNameLookup && !HaveNameProxy(), 256) && !resolved.empty()) {
396396
addrConnect = CAddress(resolved[GetRand(resolved.size())], NODE_NONE);
397397
if (!addrConnect.IsValid()) {
398-
LogPrint(BCLog::NET, "Resolver returned invalid address %s for %s", addrConnect.ToString(), pszDest);
398+
LogPrint(BCLog::NET, "Resolver returned invalid address %s for %s\n", addrConnect.ToString(), pszDest);
399399
return nullptr;
400400
}
401401
// It is possible that we already have a connection to the IP/port pszDest resolved to.

src/net_processing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
20592059

20602060
const CBlockIndex* pindex = LookupBlockIndex(req.blockhash);
20612061
if (!pindex || !(pindex->nStatus & BLOCK_HAVE_DATA)) {
2062-
LogPrint(BCLog::NET, "Peer %d sent us a getblocktxn for a block we don't have", pfrom->GetId());
2062+
LogPrint(BCLog::NET, "Peer %d sent us a getblocktxn for a block we don't have\n", pfrom->GetId());
20632063
return true;
20642064
}
20652065

@@ -2071,7 +2071,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
20712071
// might maliciously send lots of getblocktxn requests to trigger
20722072
// expensive disk reads, because it will require the peer to
20732073
// actually receive all the data read from disk over the network.
2074-
LogPrint(BCLog::NET, "Peer %d sent us a getblocktxn for a block > %i deep", pfrom->GetId(), MAX_BLOCKTXN_DEPTH);
2074+
LogPrint(BCLog::NET, "Peer %d sent us a getblocktxn for a block > %i deep\n", pfrom->GetId(), MAX_BLOCKTXN_DEPTH);
20752075
CInv inv;
20762076
inv.type = State(pfrom->GetId())->fWantsCmpctWitness ? MSG_WITNESS_BLOCK : MSG_BLOCK;
20772077
inv.hash = req.blockhash;

src/rpc/blockchain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ UniValue pruneblockchain(const JSONRPCRequest& request)
940940
else if (height > chainHeight)
941941
throw JSONRPCError(RPC_INVALID_PARAMETER, "Blockchain is shorter than the attempted prune height.");
942942
else if (height > chainHeight - MIN_BLOCKS_TO_KEEP) {
943-
LogPrint(BCLog::RPC, "Attempt to prune blocks close to the tip. Retaining the minimum number of blocks.");
943+
LogPrint(BCLog::RPC, "Attempt to prune blocks close to the tip. Retaining the minimum number of blocks.\n");
944944
height = chainHeight - MIN_BLOCKS_TO_KEEP;
945945
}
946946

src/timedata.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
110110

111111
if (LogAcceptCategory(BCLog::NET)) {
112112
for (int64_t n : vSorted) {
113-
LogPrint(BCLog::NET, "%+d ", n);
113+
LogPrint(BCLog::NET, "%+d ", n); /* Continued */
114114
}
115-
LogPrint(BCLog::NET, "| ");
115+
LogPrint(BCLog::NET, "| "); /* Continued */
116116

117117
LogPrint(BCLog::NET, "nTimeOffset = %+d (%+d minutes)\n", nTimeOffset, nTimeOffset/60);
118118
}

src/wallet/coinselection.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,10 @@ bool KnapsackSolver(const CAmount& nTargetValue, std::vector<CInputCoin>& vCoins
286286
}
287287

288288
if (LogAcceptCategory(BCLog::SELECTCOINS)) {
289-
LogPrint(BCLog::SELECTCOINS, "SelectCoins() best subset: ");
289+
LogPrint(BCLog::SELECTCOINS, "SelectCoins() best subset: "); /* Continued */
290290
for (unsigned int i = 0; i < vValue.size(); i++) {
291291
if (vfBest[i]) {
292-
LogPrint(BCLog::SELECTCOINS, "%s ", FormatMoney(vValue[i].txout.nValue));
292+
LogPrint(BCLog::SELECTCOINS, "%s ", FormatMoney(vValue[i].txout.nValue)); /* Continued */
293293
}
294294
}
295295
LogPrint(BCLog::SELECTCOINS, "total %s\n", FormatMoney(nBest));

0 commit comments

Comments
 (0)