diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py index f7c6eb904..2aa26ce15 100644 --- a/qutebrowser/qutebrowser.py +++ b/qutebrowser/qutebrowser.py @@ -23,6 +23,7 @@ import sys import json import qutebrowser +from qutebrowser.utils import log try: from qutebrowser.misc.checkpyver import check_python_version except ImportError: @@ -81,7 +82,7 @@ def get_argparser(): help="Set loglevel", default='info', choices=['critical', 'error', 'warning', 'info', 'debug', 'vdebug']) - debug.add_argument('--logfilter', + debug.add_argument('--logfilter', type=logfilter_error, help="Comma-separated list of things to be logged " "to the debug log on stdout.") debug.add_argument('--loglines', @@ -139,6 +140,14 @@ def get_argparser(): return parser +def logfilter_error(logfilter): + if set(logfilter.split(',')).issubset(log.LOGGER_NAMES)==False: + raise argparse.ArgumentTypeError("filters: Invalid value {} - expected one " + "of: {}".format(logfilter, + ', '.join(log.LOGGER_NAMES))) + return logfilter + + def main(): parser = get_argparser() if sys.platform == 'darwin' and getattr(sys, 'frozen', False):