mirror of https://github.com/zulip/zulip.git
lint: Initialize logger inside zulint.
This also helps move verbose_timing logic inside zulint.
This commit is contained in:
parent
b6d4438726
commit
0b12ec1417
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
|
@ -67,13 +66,6 @@ def run():
|
|||
# Invoke the appropriate lint checker for each language,
|
||||
# and also check files for extra whitespace.
|
||||
|
||||
logging.basicConfig(format="%(asctime)s %(message)s")
|
||||
logger = logging.getLogger()
|
||||
if args.verbose_timing:
|
||||
logger.setLevel(logging.INFO)
|
||||
else:
|
||||
logger.setLevel(logging.WARNING)
|
||||
|
||||
linter_config = LinterConfig(by_lang)
|
||||
linter_config.external_linter('add_class', ['tools/find-add-class'], ['js'])
|
||||
linter_config.external_linter('css', ['node', 'node_modules/.bin/stylelint'], ['css', 'scss'])
|
||||
|
|
|
@ -114,6 +114,15 @@ class LinterConfig:
|
|||
|
||||
self.lint_functions[name] = run_linter
|
||||
|
||||
def set_logger(self, verbose_timing):
|
||||
# type: (bool) -> None
|
||||
logging.basicConfig(format="%(asctime)s %(message)s")
|
||||
logger = logging.getLogger()
|
||||
if verbose_timing:
|
||||
logger.setLevel(logging.INFO)
|
||||
else:
|
||||
logger.setLevel(logging.WARNING)
|
||||
|
||||
def do_lint(self, args):
|
||||
# type: (argparse.Namespace) -> None
|
||||
assert not args.only or not args.skip, "Only one of --only or --skip can be used at once."
|
||||
|
@ -124,6 +133,7 @@ class LinterConfig:
|
|||
if args.list:
|
||||
print("\n".join(self.lint_functions.keys()))
|
||||
sys.exit()
|
||||
self.set_logger(args.verbose_timing)
|
||||
|
||||
failed = run_parallel(self.lint_functions)
|
||||
sys.exit(1 if failed else 0)
|
||||
|
|
Loading…
Reference in New Issue