From c7e87700072078d2235c3cca3b7d45c1904a57e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sverrir=20Arno=CC=81rsson?= Date: Mon, 3 Apr 2023 18:15:37 +0000 Subject: [PATCH 1/2] Update interface.py --- keepa/interface.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/keepa/interface.py b/keepa/interface.py index 766cbae..04f260e 100644 --- a/keepa/interface.py +++ b/keepa/interface.py @@ -25,7 +25,6 @@ def wrapper(target): log = logging.getLogger(__name__) -log.setLevel("DEBUG") # hardcoded ordinal time from KEEPA_ST_ORDINAL = np.datetime64("2011-01-01") @@ -358,6 +357,10 @@ class Keepa: raised if the server has not issued a response for timeout seconds. Setting this to 0 disables the timeout, but will cause any request to hang indefiantly should keepa.com be down + + logging_level: string, optional + Logging level to use. Default is 'DEBUG'. Other options are + 'INFO', 'WARNING', 'ERROR', and 'CRITICAL'. Examples -------- @@ -391,13 +394,20 @@ class Keepa: """ - def __init__(self, accesskey, timeout=10): + def __init__(self, accesskey, timeout=10, logging_level="DEBUG"): """Initialize server connection.""" self.accesskey = accesskey self.status = None self.tokens_left = 0 self._timeout = timeout + # Set up logging + levels = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] + if logging_level not in levels: + raise TypeError( + "logging_level must be one of: " + ", ".join(levels) + ) + log.setLevel(logging_level) # Store user's available tokens log.info("Connecting to keepa using key ending in %s", accesskey[-6:]) self.update_status() From 916277dd23bb7c58898b210bbc5e1e47c0812ef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sverrir=20Arno=CC=81rsson?= Date: Mon, 3 Apr 2023 18:24:45 +0000 Subject: [PATCH 2/2] fix codacy error --- keepa/interface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keepa/interface.py b/keepa/interface.py index 04f260e..0fedb94 100644 --- a/keepa/interface.py +++ b/keepa/interface.py @@ -357,7 +357,7 @@ class Keepa: raised if the server has not issued a response for timeout seconds. Setting this to 0 disables the timeout, but will cause any request to hang indefiantly should keepa.com be down - + logging_level: string, optional Logging level to use. Default is 'DEBUG'. Other options are 'INFO', 'WARNING', 'ERROR', and 'CRITICAL'.