Skip to content

Commit f138a14

Browse files
laanwjDuddino
authored andcommitted
add lint-logs.sh to check for newline termination. (bitcoin#12891)
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
1 parent 6717891 commit f138a14

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

contrib/devtools/lint-logs.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2018 The Bitcoin Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
#
7+
# Check that all logs are terminated with '\n'
8+
#
9+
# Some logs are continued over multiple lines. They should be explicitly
10+
# commented with \* Continued *\
11+
#
12+
# There are some instances of LogPrintf() in comments. Those can be
13+
# ignored
14+
15+
16+
UNTERMINATED_LOGS=$(git grep "LogPrintf(" -- "*.cpp" | \
17+
grep -v '\\n"' | \
18+
grep -v "/\* Continued \*/" | \
19+
grep -v "LogPrintf()")
20+
if [[ ${UNTERMINATED_LOGS} != "" ]]; then
21+
printf "All calls to LogPrintf() should be terminated with \\n \n"
22+
printf "\n"
23+
printf "${UNTERMINATED_LOGS}\n"
24+
exit 1
25+
fi

src/validation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3706,14 +3706,14 @@ bool CVerifyDB::VerifyDB(CCoinsView* coinsview, int nCheckLevel, int nCheckDepth
37063706
CBlockIndex* pindexFailure = nullptr;
37073707
int nGoodTransactions = 0;
37083708
int reportDone = 0;
3709-
LogPrintf("[0%%]...");
3709+
LogPrintf("[0%%]..."); /* Continued */
37103710
CValidationState state;
37113711
for (CBlockIndex* pindex = chainActive.Tip(); pindex && pindex->pprev; pindex = pindex->pprev) {
37123712
boost::this_thread::interruption_point();
37133713
int percentageDone = std::max(1, std::min(99, (int)(((double)(chainActive.Height() - pindex->nHeight)) / (double)nCheckDepth * (nCheckLevel >= 4 ? 50 : 100))));
37143714
if (reportDone < percentageDone/10) {
37153715
// report every 10% step
3716-
LogPrintf("[%d%%]...", percentageDone);
3716+
LogPrintf("[%d%%]...", percentageDone); /* Continued */
37173717
reportDone = percentageDone/10;
37183718
}
37193719
uiInterface.ShowProgress(_("Verifying blocks..."), percentageDone);

0 commit comments

Comments
 (0)