[check-googlefonts] add some CLI control over reported loglevels.
@@ -5,12 +5,33 @@ from __future__ import absolute_import, print_function, unicode_literals
import logging
import argparse
import glob
+from collections import OrderedDict
from fontbakery.testrunner import (
distribute_generator
, TestRunner
, Spec
+ , DEBUG
+ , INFO
+ , WARN
+ , ERROR
+ , SKIP
+ , PASS
+ , FAIL
)
+
+log_levels = OrderedDict((s.name,s) for s in sorted((
+ DEBUG
+ , INFO
+ , WARN
+ , ERROR
+ , SKIP
+ , PASS
+ , FAIL
+ )))
+
+
+
from fontbakery.reporters.terminal import TerminalReporter
from fontbakery.reporters.serialize import SerializeReporter
from fontbakery.specifications.googlefonts import specificiation as specificiation
@@ -24,6 +45,21 @@ parser.add_argument('arg_filepaths', nargs='+',
parser.add_argument('-c', '--checkid', action='append',
help='Explicit check-ids to be executed.')
+
+def log_levels_get(key):
+ if key in log_levels:
+ return log_levels[key]
+ raise argparse.ArgumentTypeError('Key "{}" must be one of: {}.'.format(
+ key, ', '.join(log_levels.keys())))
+
+parser.add_argument('-l', '--loglevel-tests', default=None, type=log_levels_get,
+ help='Report tests with a result of this status or higher.\n'
+ 'One of: {}'.format(', '.join(log_levels.keys())))
+
+parser.add_argument('-m', '--loglevel-messages', default=None, type=log_levels_get,
+ help='Report log messages of this status or higher.\n'
+ 'One of: {}'.format(', '.join(log_levels.keys())))
+
def get_fonts(globs):
fonts_to_check = []
for target in globs:
@@ -40,8 +76,11 @@ if __name__ == '__main__':
args = parser.parse_args()
values = dict(fonts=get_fonts(args.arg_filepaths))
runner = TestRunner(specificiation, values, explicit_tests=args.checkid)
+
tr = TerminalReporter(runner=runner, is_async=False, print_progress=True
- #, collect_results_by='font'
+ , test_threshold=args.loglevel_tests
+ , log_threshold=args.loglevel_messages
+ , collect_results_by='font'
)
# sr = SerializeReporter(runner=runner, collect_results_by='font')
distribute_generator(runner.run(), [tr.receive])# sr.receive
