# HG changeset patch # User Ludovic Chabant # Date 1439755339 25200 # Node ID 353a0b30f412f1ca4ebc5a433f59c893b62a1d83 # Parent e7fb848fd55d94398b3c8056778060ac9ecea931 chef: Add `--debug-only` option to only show debug logging for a given logger. diff -r e7fb848fd55d -r 353a0b30f412 piecrust/main.py --- a/piecrust/main.py Fri Aug 14 22:57:59 2015 -0700 +++ b/piecrust/main.py Sun Aug 16 13:02:19 2015 -0700 @@ -85,6 +85,7 @@ self.log_debug = log_debug self.config_variant = config_variant self.config_values = [] + self.debug_only = [] def _parse_config_value(arg): @@ -125,6 +126,9 @@ i += 1 elif arg == '--log-debug': res.log_debug = True + elif arg == '--debug-only': + res.debug_only.append(argv[i + 1]) + i += 1 elif arg == '--no-cache': res.cache = False elif arg == '--debug': @@ -146,8 +150,11 @@ if res.debug or res.log_debug: root_logger.setLevel(logging.DEBUG) + for n in res.debug_only: + logging.getLogger(n).setLevel(logging.DEBUG) + log_handler = logging.StreamHandler(sys.stdout) - if res.debug: + if res.debug or res.debug_only: log_handler.setLevel(logging.DEBUG) log_handler.setFormatter(ColoredFormatter("[%(name)s] %(message)s")) else: @@ -219,6 +226,9 @@ '--debug', help="Show debug information.", action='store_true') parser.add_argument( + '--debug-only', + help="Only show debug information for the given categories.") + parser.add_argument( '--no-cache', help="When applicable, disable caching.", action='store_true')