From c81a437af6567c0f0462658942c7967c28656bcf Mon Sep 17 00:00:00 2001 From: Uchechukwu Orji Date: Sat, 3 Aug 2024 14:03:52 +0100 Subject: [PATCH] log cli actions --- backend/src/mirrors_qa_backend/cli/worker.py | 3 --- backend/src/mirrors_qa_backend/entrypoint.py | 7 +++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/src/mirrors_qa_backend/cli/worker.py b/backend/src/mirrors_qa_backend/cli/worker.py index 31b5601..b39914d 100644 --- a/backend/src/mirrors_qa_backend/cli/worker.py +++ b/backend/src/mirrors_qa_backend/cli/worker.py @@ -1,7 +1,6 @@ import pycountry from cryptography.hazmat.primitives import serialization -from mirrors_qa_backend import logger from mirrors_qa_backend.db import Session from mirrors_qa_backend.db.country import update_countries as update_db_countries from mirrors_qa_backend.db.worker import create_worker as create_db_worker @@ -51,8 +50,6 @@ def create_worker( public_key, # pyright: ignore [reportGeneralTypeIssues, reportArgumentType] ) - logger.info(f"Created worker {worker_id} successfully") - def update_worker(worker_id: str, country_codes: list[str]): """Update worker's data. diff --git a/backend/src/mirrors_qa_backend/entrypoint.py b/backend/src/mirrors_qa_backend/entrypoint.py index 54ec37d..53fdea4 100644 --- a/backend/src/mirrors_qa_backend/entrypoint.py +++ b/backend/src/mirrors_qa_backend/entrypoint.py @@ -101,11 +101,14 @@ def main(): if args.cli_name == UPDATE_MIRRORS_CLI: try: + logger.debug("Updating list of mirrors...") update_mirrors() except Exception as exc: logger.error(f"error while updating mirrors: {exc!s}") sys.exit(1) + logger.info("Updated list of mirrors on database.") elif args.cli_name == SCHEDULER_CLI: + logger.debug("Starting scheduler task...") start_scheduler( args.scheduler_sleep_seconds, args.expire_tests_since, @@ -113,6 +116,7 @@ def main(): ) elif args.cli_name == CREATE_WORKER_CLI: try: + logger.debug(f"Creating worker {args.worker_id!r}...") create_worker( args.worker_id, bytes(args.public_key_file.read(), encoding="ascii"), @@ -121,8 +125,10 @@ def main(): except Exception as exc: logger.error(f"error while creating worker: {exc!s}") sys.exit(1) + logger.info(f"Saved worker {args.worker_id!r} to database.") elif args.cli_name == UPDATE_WORKER_CLI: try: + logger.debug(f"Updating list of mirrors for {args.worker_id!r}") update_worker( args.worker_id, args.countries if args.countries else [], @@ -130,6 +136,7 @@ def main(): except Exception as exc: logger.error(f"error while updating worker: {exc!s}") sys.exit(1) + logger.info(f"Updated countries for worker {args.worker_id!r}") else: args.print_help()