From 816ddb12b0fd46e9a71e9e4eb7030d1e6a3ba8f1 Mon Sep 17 00:00:00 2001 From: Benedikt Ziemons Date: Fri, 18 Mar 2022 15:41:25 +0100 Subject: [PATCH] Add verbose logging --- imagerebuild.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/imagerebuild.py b/imagerebuild.py index 067ac1f..3d552b7 100755 --- a/imagerebuild.py +++ b/imagerebuild.py @@ -17,6 +17,8 @@ def resolve_image_units(): services_list = list(map(lambda p: str(p.name), services_path.iterdir())) image_units: Set[str] = set() + logging.info(f"Found {len(services_list)} services: {str(services_list)}") + def process_pod_systemctl_show(line: str): search_str = "Wants=" if line.startswith(search_str): @@ -61,11 +63,19 @@ def resolve_image_units(): bar.length += len(new_image_units) previous_image_units = set(image_units) + logging.info(f"Found {len(image_units)} images: {str(image_units)}") return image_units -def main(): - logging.basicConfig(level=logging.CRITICAL) +@click.command() +@click.option("--verbose", is_flag=True, default=False, help="Enable INFO logging") +def main(verbose): + if verbose: + loglevel = logging.INFO + else: + loglevel = logging.CRITICAL + + logging.basicConfig(level=loglevel) image_units = resolve_image_units() image_tags: Set[str] = set()