Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Unified Diff: PRESUBMIT.py

Issue 787013005: Only presubmit warn when spammy logging is being added/modified. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: use ChangedContents Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT.py
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index ce66452fea9c7a999e0740125ea176d1893f5dc1..4f7cca5d826cef063c816dabda4b6c1293b0f052 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -1009,20 +1009,20 @@ def _CheckSpamLogging(input_api, output_api):
source_file_filter = lambda x: input_api.FilterSourceFile(
x, white_list=(file_inclusion_pattern,), black_list=black_list)
+ log_macro = input_api.re.compile(r"\bD?LOG\s*\(\s*INFO\s*\)")
+ log_if_macro = input_api.re.compile(r"\bD?LOG_IF\s*\(\s*INFO\s*,")
+ printf_macro = input_api.re.compile(r"\bprintf\(")
+ fprintf_macro = input_api.re.compile(r"\bfprintf\((stdout|stderr)")
+
log_info = []
printf = []
for f in input_api.AffectedSourceFiles(source_file_filter):
- contents = input_api.ReadFile(f, 'rb')
- if input_api.re.search(r"\bD?LOG\s*\(\s*INFO\s*\)", contents):
- log_info.append(f.LocalPath())
- elif input_api.re.search(r"\bD?LOG_IF\s*\(\s*INFO\s*,", contents):
- log_info.append(f.LocalPath())
-
- if input_api.re.search(r"\bprintf\(", contents):
- printf.append(f.LocalPath())
- elif input_api.re.search(r"\bfprintf\((stdout|stderr)", contents):
- printf.append(f.LocalPath())
+ for linenum, line in f.ChangedContents():
+ if log_macro.search(line) or log_if_macro.search(line):
+ log_info.append(f.LocalPath())
+ if printf_macro.search(line) or fprintf_macro.search(line):
+ printf.append(f.LocalPath())
if log_info:
return [output_api.PresubmitError(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698