From 6f4a991ab3f311c9b6792f06f7c0324d43ef00e5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 22 Jun 2023 06:43:30 +0200 Subject: [PATCH] Continued: - global parameter --debug added, produces with large blocks.db file a lot of output! You have been warned! --- fba/boot.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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!") -- 2.39.5