From e4a28d744609d1e67442bab179354966d9d6310f Mon Sep 17 00:00:00 2001 From: marcsello Date: Wed, 14 Apr 2021 21:16:20 +0200 Subject: [PATCH] Added more logging --- single_ursim_control/program_loader.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/single_ursim_control/program_loader.py b/single_ursim_control/program_loader.py index 9571f58..0eae2f2 100644 --- a/single_ursim_control/program_loader.py +++ b/single_ursim_control/program_loader.py @@ -1,14 +1,21 @@ from program_schema import ProgramSchema, SUPPORTED_PROGRAM_STRUCTURE_VERSION import requests +import logging + def load_program(url: str) -> dict: + logger = logging.getLogger('loader') headers = { - 'Accept': 'application/json' + 'Accept': 'application/json', } + logger.debug(f"Performing HTTP request: (url: {url}, headers: {headers})") r = requests.get(url, headers=headers) r.raise_for_status() + logger.debug(f"HTTP Status: {r.status_code}; Validating downloaded info...") program_schema = ProgramSchema(many=False) + program = program_schema.load(r.json()) # Might raise marshmallow exceptions - return program_schema.load(r.json()) # Might raise marshmallow exceptions + logger.info(f"Loaded {program.get('name')} (Created at: {program.get('created_at')}) from {url}") + return program