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
This commit is contained in:
parent
c626c2a87e
commit
ec14619ef0
@ -35,7 +35,22 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
HTTPSConnectionNoSSLComp = HTTPSConnection
|
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 = logging.getLogger("swiftclient")
|
||||||
|
logger.addHandler(NullHandler())
|
||||||
|
|
||||||
|
|
||||||
def http_log(args, kwargs, resp, body):
|
def http_log(args, kwargs, resp, body):
|
||||||
|
Loading…
Reference in New Issue
Block a user