From 0ed64d61c91dc0eb36df69d00aaa611c860181c2 Mon Sep 17 00:00:00 2001 From: Jeroen van der Heijden Date: Mon, 21 Nov 2022 22:27:19 +0100 Subject: [PATCH] Improve log, upd version --- pylibagent/agent.py | 11 ++++++++--- pylibagent/version.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pylibagent/agent.py b/pylibagent/agent.py index 0467c71..069cc40 100644 --- a/pylibagent/agent.py +++ b/pylibagent/agent.py @@ -14,6 +14,10 @@ from .check import CheckBase +class SendDataException(Exception): + pass + + def _convert_verify_ssl(val): if val is None or val.lower() in ['true', '1', 'y', 'yes']: return None # None for default SSL check @@ -140,9 +144,8 @@ async def send_data(self, check_key: str, data: dict, except Exception as e: msg = str(e) or type(e).__name__ - logging.error( - 'failed to send data for ' - f'check {check_key}: {msg} (url: {url})') + raise SendDataException( + f'failed to send data ({check_key}): {msg} (url: {url})') def start(self, checks: Iterable[CheckBase], asset_name: Optional[str] = None): @@ -209,6 +212,8 @@ async def _check_loop(self, check): except Exception as e: msg = str(e) or type(e).__name__ logging.error(f'check error ({check.key}): {msg}') + except SendDataException as e: + logging.error(str(e)) else: logging.debug(f'check_loop ({check.key}): ok!') finally: diff --git a/pylibagent/version.py b/pylibagent/version.py index 66a87bb..2fb2513 100644 --- a/pylibagent/version.py +++ b/pylibagent/version.py @@ -1 +1 @@ -__version__ = '0.1.5' +__version__ = '0.1.6'