summaryrefslogtreecommitdiffstats
path: root/PRESUBMIT.py
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-22 07:41:40 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-22 07:41:40 +0000
commit852185659ee97b95d751e6523d994f168aa84c3b (patch)
treebe077174de099f06f0866f93e7aa58cd8aafdd91 /PRESUBMIT.py
parent3c467a1535ea095e7fc63a8cb9eabff99c8e7041 (diff)
downloadchromium_src-852185659ee97b95d751e6523d994f168aa84c3b.zip
chromium_src-852185659ee97b95d751e6523d994f168aa84c3b.tar.gz
chromium_src-852185659ee97b95d751e6523d994f168aa84c3b.tar.bz2
Move CheckSpamLogging from cc's PRESUBMIT into the global PRESUBMIT
See thread "[chromium-dev] Say no to excessive debug logging" BUG=none Review URL: https://codereview.chromium.org/79173008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236715 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'PRESUBMIT.py')
-rw-r--r--PRESUBMIT.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 33e13a58..1c1e491 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -827,6 +827,37 @@ def _CheckAddedDepsHaveTargetApprovals(input_api, output_api):
return []
+def _CheckSpamLogging(input_api, output_api):
+ file_inclusion_pattern = r'.+%s' % _IMPLEMENTATION_EXTENSIONS
+ black_list = (_EXCLUDED_PATHS +
+ _TEST_CODE_EXCLUDED_PATHS +
+ input_api.DEFAULT_BLACK_LIST +
+ (r"^base[\\\/]logging\.h$",))
+ source_file_filter = lambda x: input_api.FilterSourceFile(
+ x, white_list=(file_inclusion_pattern,), black_list=black_list)
+
+ log_info = []
+ printf = []
+
+ for f in input_api.AffectedSourceFiles(source_file_filter):
+ contents = input_api.ReadFile(f, 'rb')
+ if re.search(r"\bD?LOG\s*\(\s*INFO\s*\)", contents):
+ log_info.append(f.LocalPath())
+ if re.search(r"\bf?printf\(", contents):
+ printf.append(f.LocalPath())
+
+ if log_info:
+ return [output_api.PresubmitError(
+ 'These files spam the console log with LOG(INFO):',
+ items=log_info)]
+ if printf:
+ return [output_api.PresubmitError(
+ 'These files spam the console log with printf/fprintf:',
+ items=printf)]
+ return []
+
+
+
def _CommonChecks(input_api, output_api):
"""Checks common to both upload and commit."""
results = []
@@ -857,6 +888,7 @@ def _CommonChecks(input_api, output_api):
input_api,
output_api,
source_file_filter=lambda x: x.LocalPath().endswith('.grd')))
+ results.extend(_CheckSpamLogging(input_api, output_api))
if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()):
results.extend(input_api.canned_checks.RunUnitTestsInDirectory(