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

Unified Diff: PRESUBMIT.py

Issue 1114593002: [android log] Add documentation and presubmit checks for log usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months 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 | PRESUBMIT_test.py » ('j') | 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 71360cb81daf0ce118c0391d322433c56f038e22..8f5d3b9ea84103134470675b3fbf9c17f73426e4 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -1300,6 +1300,35 @@ def _CheckJavaStyle(input_api, output_api):
black_list=_EXCLUDED_PATHS + input_api.DEFAULT_BLACK_LIST)
+def _CheckNoNewUtilLogUsage(input_api, output_api):
+ """Checks that new logs are using org.chromium.base.Log."""
+
+ chromium_log_import_pattern = input_api.re.compile(
+ r'^import org\.chromium\.base\.Log;$', input_api.re.MULTILINE);
+ log_pattern = input_api.re.compile(r'^\s*(android\.util\.)?Log\.\w')
+ sources = lambda x: input_api.FilterSourceFile(x, white_list=(r'.*\.java$',))
+
+ errors = []
+
+ for f in input_api.AffectedSourceFiles(sources):
+ if chromium_log_import_pattern.search(input_api.ReadFile(f)) is not None:
+ # Uses org.chromium.base.Log already
+ continue
+
+ for line_num, line in f.ChangedContents():
+ if log_pattern.search(line):
+ errors.append("%s:%d" % (f.LocalPath(), line_num))
+
+ results = []
+ if len(errors):
+ results.append(output_api.PresubmitPromptWarning(
+ 'Please use org.chromium.base.Log for new logs.\n' +
+ 'See base/android/java/src/org/chromium/base/README_logging.md ' +
+ 'or contact dgn@chromium.org for more info.',
+ errors))
+ return results
+
+
def _CheckForCopyrightedCode(input_api, output_api):
"""Verifies that newly added code doesn't contain copyrighted material
and is properly licensed under the standard Chromium license.
@@ -1468,6 +1497,7 @@ def _CommonChecks(input_api, output_api):
results.extend(_CheckForCopyrightedCode(input_api, output_api))
results.extend(_CheckForWindowsLineEndings(input_api, output_api))
results.extend(_CheckSingletonInHeaders(input_api, output_api))
+ results.extend(_CheckNoNewUtilLogUsage(input_api, output_api))
if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()):
results.extend(input_api.canned_checks.RunUnitTestsInDirectory(
« no previous file with comments | « no previous file | PRESUBMIT_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698