| 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(
|
|
|