diff --git a/setup.py b/setup.py index 1d5ea98..dc8e3d5 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name = 'splunk_handler', - version = '1.1.0', + version = '1.1.1', license = 'MIT License', description = 'A Python logging handler that sends your logs to Splunk', long_description = open('README.md').read(), diff --git a/splunk_handler/__init__.py b/splunk_handler/__init__.py index 3663813..b8ada1b 100644 --- a/splunk_handler/__init__.py +++ b/splunk_handler/__init__.py @@ -31,9 +31,12 @@ def __init__(self, host, port, username, password, index, else: self.hostname = hostname - # prevent infinite recursion by silencing requests logger - requests_log = logging.getLogger('requests') - requests_log.propagate = False + # prevent infinite recursion by silencing requests and urllib3 loggers + logging.getLogger('requests').propagate = False + logging.getLogger('urllib3').propagate = False + + # and do the same for ourselves + logging.getLogger(__name__).propagate = False def emit(self, record): @@ -71,7 +74,9 @@ def _async_emit(self, record): r.close() except Exception, e: - - print "Traceback:\n" + traceback.format_exc() - print "Exception in Splunk logging handler: %s" % str(e) + try: + print traceback.format_exc() + print "Exception in Splunk logging handler: %s" % str(e) + except: + pass