Skip to content

Commit

Permalink
feat: enable more verbose logging level according to the app config
Browse files Browse the repository at this point in the history
  • Loading branch information
kikkomep committed Feb 26, 2024
1 parent ee7796f commit d2ead99
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 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 @@ -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)
Expand Down

0 comments on commit d2ead99

Please sign in to comment.