From 043e43ae63490b11484edcf8f05cc8ebd88003c8 Mon Sep 17 00:00:00 2001 From: bossenti Date: Thu, 19 Oct 2023 21:14:35 +0200 Subject: [PATCH] refactor: make logging level configurable Signed-off-by: bossenti --- vistafetch/client.py | 4 ++-- vistafetch/logs.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vistafetch/client.py b/vistafetch/client.py index 1c6be6e..f794ba5 100644 --- a/vistafetch/client.py +++ b/vistafetch/client.py @@ -24,8 +24,8 @@ class VistaFetchClient: client_headers: additional headers to be sent with every request, optional """ - def __init__(self, client_headers: Optional[Dict[str, str]] = None): - set_up_logging() + def __init__(self, client_headers: Optional[Dict[str, str]] = None, logging_level: Optional[int] = None): + set_up_logging(logging_level=logging_level) http_headers = {"Application": "application/json; charset=utf-8"} diff --git a/vistafetch/logs.py b/vistafetch/logs.py index 6e1589e..0bcd76f 100644 --- a/vistafetch/logs.py +++ b/vistafetch/logs.py @@ -8,11 +8,11 @@ ] -def set_up_logging() -> None: +def set_up_logging(logging_level: int = logging.INFO) -> None: """Configure logging.""" log_format = "%(message)s" logging.basicConfig( - level="NOTSET", format=log_format, datefmt="[%X]", handlers=[RichHandler()] + level=logging_level, format=log_format, datefmt="[%X]", handlers=[RichHandler()] ) logging.debug("Logging set up successfully.")