From db74ce9aa9ca7ffae9eb93b2037c4311805d3132 Mon Sep 17 00:00:00 2001 From: Will Maier Date: Thu, 6 Jan 2011 10:27:04 -0600 Subject: add logging boilerplate --- redis/client.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'redis/client.py') diff --git a/redis/client.py b/redis/client.py index 967bcee..c473444 100644 --- a/redis/client.py +++ b/redis/client.py @@ -1,5 +1,6 @@ import datetime import errno +import logging import socket import threading import time @@ -8,6 +9,16 @@ from itertools import chain, imap from redis.exceptions import ConnectionError, ResponseError, InvalidResponse, WatchError from redis.exceptions import RedisError, AuthenticationError +try: + NullHandler = logging.NullHandler +except AttributeError: + class NullHandler(logging.Handler): + def emit(self, record): pass + +log = logging.getLogger("redis") +# Add a no-op handler to avoid error messages if the importing module doesn't +# configure logging. +log.addHandler(NullHandler()) class ConnectionPool(threading.local): "Manages a list of connections on the local thread" -- cgit v1.2.1