Skip to content

Commit

Permalink
Merge pull request #4 from sullivanmatt/master
Browse files Browse the repository at this point in the history
Better error handling.
  • Loading branch information
zach-taylor committed Feb 16, 2015
2 parents 72bba54 + 0150519 commit 3da16eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
17 changes: 11 additions & 6 deletions splunk_handler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down Expand Up @@ -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

0 comments on commit 3da16eb

Please sign in to comment.