Skip to content

Commit d0f7493

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#24849: lint: Convert lint-logs.sh to Python
e9d2771 lint: Convert lint-logs.sh to Python (Dimitri) Pull request description: A port of `/test/lint/lint-logs.sh` to a Python-script as part of the request of #24783 . Checked for output-consistency. Removed all non-explicit exceptions (i.e. `...`, `LogPrint()`, and `LogPrintf()`) because they weren't needed anymore, except for one single case in a comment in `/src/random.cpp` which I removed because it was quite useless anyway (the comment, not the file). ACKs for top commit: laanwj: Code review ACK e9d2771 Tree-SHA512: ae4d2a341a13ccd9f40e8fcde35e1f392d9995131be005b809cbf8f283f28a7c34ea3cf9c13d3564d13809ae3f5889260fa5d6302370dc79c3226389974d947c
2 parents b69fd5e + e9d2771 commit d0f7493

File tree

3 files changed

+35
-29
lines changed

3 files changed

+35
-29
lines changed

src/random.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <compat.h> // for Windows API
1414
#include <wincrypt.h>
1515
#endif
16-
#include <logging.h> // for LogPrintf()
16+
#include <logging.h>
1717
#include <randomenv.h>
1818
#include <support/allocators/secure.h>
1919
#include <sync.h> // for Mutex

test/lint/lint-logs.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Copyright (c) 2018-2022 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+
import re
13+
import sys
14+
15+
from subprocess import check_output
16+
17+
18+
def main():
19+
logs_list = check_output(["git", "grep", "--extended-regexp", r"LogPrintf?\(", "--", "*.cpp"], universal_newlines=True, encoding="utf8").splitlines()
20+
21+
unterminated_logs = [line for line in logs_list if not re.search(r'(\\n"|/\* Continued \*/)', line)]
22+
23+
if unterminated_logs != []:
24+
print("All calls to LogPrintf() and LogPrint() should be terminated with \\n")
25+
print("")
26+
27+
for line in unterminated_logs:
28+
print(line)
29+
30+
sys.exit(1)
31+
32+
33+
if __name__ == "__main__":
34+
main()

test/lint/lint-logs.sh

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)