From ec14619ef05a2f2571805466956a1f0f567a1eea Mon Sep 17 00:00:00 2001 From: Clay Gerrard Date: Thu, 15 Aug 2013 18:46:33 -0700 Subject: [PATCH] Add a NullHandler when setting up library logging I was gunna write a test, but mocking ImportErrors is a PITA, so I decided to just get my tox py26 working instead. Tests seem to fail/pass as expected without/with the inline NullHanlder. Closes-Bug: 1212861 Change-Id: I20207374a77ee9969ab201c3a57e4caf40c02a61 --- swiftclient/client.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/swiftclient/client.py b/swiftclient/client.py index eef5b6c1..a95ce707 100644 --- a/swiftclient/client.py +++ b/swiftclient/client.py @@ -35,7 +35,22 @@ try: except ImportError: HTTPSConnectionNoSSLComp = HTTPSConnection + +try: + from logging import NullHandler +except ImportError: + class NullHandler(logging.Handler): + def handle(self, record): + pass + + def emit(self, record): + pass + + def createLock(self): + self.lock = None + logger = logging.getLogger("swiftclient") +logger.addHandler(NullHandler()) def http_log(args, kwargs, resp, body):