Skip to content

Commit

Permalink
Merge pull request #379 from kikkomep/fix/too-verbose-redis-log
Browse files Browse the repository at this point in the history
Fix: configure verbosity of redis logs
  • Loading branch information
kikkomep authored Feb 27, 2024
2 parents 9882fbf + d2ead99 commit 7e78d25
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lifemonitor/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -37,4 +40,17 @@ def init(app: Flask) -> Redis:
port=int(app.config.get("REDIS_PORT_NUMBER", 6379)),
password=app.config.get("REDIS_PASSWORD", "foobar"),
db=0)

# 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)
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__

0 comments on commit 7e78d25

Please sign in to comment.