From ef606824e43804149576c67c107dc29c33c47095 Mon Sep 17 00:00:00 2001 From: Fabio Uechi <308613+fabito@users.noreply.github.com> Date: Fri, 14 Nov 2025 14:56:47 +1300 Subject: [PATCH] refactor: Ability to customize task logging configuration --- stactask/task.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/stactask/task.py b/stactask/task.py index 6425df4..cb4938d 100644 --- a/stactask/task.py +++ b/stactask/task.py @@ -461,6 +461,22 @@ def _post_process_item(self, item: dict[str, Any]) -> dict[str, Any]: item["stac_extensions"].sort() return item + @classmethod + def configure_logging(cls, loglevel: str) -> None: + """Configures logging.""" + logging.basicConfig(level=loglevel) + + # quiet these loud loggers + for ql in [ + "botocore", + "s3transfer", + "urllib3", + "fsspec", + "asyncio", + "aiobotocore", + ]: + logging.getLogger(ql).propagate = False + @classmethod def handler(cls, payload: dict[str, Any], **kwargs: Any) -> dict[str, Any]: task = None @@ -612,7 +628,7 @@ def parse_args(cls, args: list[str]) -> dict[str, Any]: if pargs.get("output") is None: pargs["output"] = Path(pargs["workdir"]) / "output-payload.json" - if pargs.get("command", None) is None: + if pargs.get("command") is None: parser.print_help() sys.exit(0) @@ -625,18 +641,7 @@ def cli(cls) -> None: # logging loglevel = args.pop("logging") - logging.basicConfig(level=loglevel) - - # quiet these loud loggers - for ql in [ - "botocore", - "s3transfer", - "urllib3", - "fsspec", - "asyncio", - "aiobotocore", - ]: - logging.getLogger(ql).propagate = False + cls.configure_logging(loglevel) if cmd == "run": href = args.pop("input", None)