From: Roland Häder Date: Thu, 22 Jun 2023 04:43:30 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6f4a991ab3f311c9b6792f06f7c0324d43ef00e5;p=fba.git Continued: - global parameter --debug added, produces with large blocks.db file a lot of output! You have been warned! --- diff --git a/fba/boot.py b/fba/boot.py index 6c49bea..052fe15 100644 --- a/fba/boot.py +++ b/fba/boot.py @@ -23,7 +23,7 @@ from fba import database from fba.helpers import locking -logging.basicConfig(level=logging.WARNING) +logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) # Argument parser @@ -38,6 +38,11 @@ def init_parser(): description="Fetches block reasons from the fediverse", epilog="Please note that some commands have optional arguments, you may want to try fba.py --help to find them out.", ) + + # Generic: + _PARSER.add_argument("--debug", action="store_const", dest="log_level", const=logging.DEBUG, help="Full debug output") + + # Commands: subparser_command = _PARSER.add_subparsers( dest="command", title="Commands to execute", @@ -141,6 +146,12 @@ def init_parser(): def run_command(): logger.debug("run_command(): CALLED!") args = _PARSER.parse_args() + + if args.log_level is not None: + loggers = [logging.getLogger(name) for name in logging.root.manager.loggerDict] + for _logger in loggers: + _logger.setLevel(args.log_level) + logger.debug(f"args[{type(args)}]={args}") status = args.command(args) logger.debug("status={status} - EXIT!")