Skip to content

Commit d207207

Browse files
committed
[logging] add lint-logs.sh to check for newline termination.
Check that all calls to LogPrintf() are terminated by a newline, except those that are explicitly marked as 'continued' logs.
1 parent 5c21e6c commit d207207

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
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+
echo "All calls to LogPrintf() should be terminated with \\n"
22+
echo
23+
echo "${UNTERMINATED_LOGS}"
24+
exit 1
25+
fi

0 commit comments

Comments
 (0)