From ee7796fead638a0d54501b3cddaef7b424d69d30 Mon Sep 17 00:00:00 2001 From: Marco Enrico Piras Date: Sun, 25 Feb 2024 21:56:04 +0100 Subject: [PATCH 1/2] fix: change log level of redis_lock module --- lifemonitor/redis.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lifemonitor/redis.py b/lifemonitor/redis.py index 29e4453b8..d584bdf11 100644 --- a/lifemonitor/redis.py +++ b/lifemonitor/redis.py @@ -37,4 +37,19 @@ def init(app: Flask) -> Redis: port=int(app.config.get("REDIS_PORT_NUMBER", 6379)), password=app.config.get("REDIS_PASSWORD", "foobar"), db=0) + + # fix logger level + import logging + + import redis_lock + + redis_lock_logger_level = logging.ERROR + redis_lock.logger_for_acquire.setLevel(redis_lock_logger_level) + redis_lock.logger_for_release.setLevel(redis_lock_logger_level) + redis_lock.logger_for_acquire.setLevel(redis_lock_logger_level) + redis_lock.logger_for_refresh_thread.setLevel(redis_lock_logger_level) + redis_lock.logger_for_refresh_start.setLevel(redis_lock_logger_level) + redis_lock.logger_for_refresh_shutdown.setLevel(redis_lock_logger_level) + redis_lock.logger_for_refresh_exit.setLevel(redis_lock_logger_level) + redis_lock.logger_for_release.setLevel(redis_lock_logger_level) return __redis__ From d2ead9933a0202a89b8c0066cfc761e6345e4aa1 Mon Sep 17 00:00:00 2001 From: Marco Enrico Piras Date: Mon, 26 Feb 2024 15:48:41 +0100 Subject: [PATCH 2/2] feat: enable more verbose logging level according to the app config --- lifemonitor/redis.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lifemonitor/redis.py b/lifemonitor/redis.py index d584bdf11..8bb3ae8de 100644 --- a/lifemonitor/redis.py +++ b/lifemonitor/redis.py @@ -18,6 +18,9 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +import logging + +import redis_lock from flask import Flask from redis import Redis @@ -38,12 +41,10 @@ def init(app: Flask) -> Redis: password=app.config.get("REDIS_PASSWORD", "foobar"), db=0) - # fix logger level - import logging - - import redis_lock - - redis_lock_logger_level = logging.ERROR + # reconfigure the logging level for the redis_lock library + redis_lock_logger_level = logging.WARNING + if app.config.get("DEBUG", False): + redis_lock_logger_level = logging.DEBUG redis_lock.logger_for_acquire.setLevel(redis_lock_logger_level) redis_lock.logger_for_release.setLevel(redis_lock_logger_level) redis_lock.logger_for_acquire.setLevel(redis_lock_logger_level)