raven
's captureException
can only be called without arguments if there is an exception active, which is not always the case when a log observer is called. So, instead, pull the exception information out of the Failure
that gets logged:
from twisted.python import log
from raven import Client
client = Client(dsn='twisted+http://YOUR_DSN_HERE')
def logToSentry(event):
if not event.get('isError') or 'failure' not in event:
return
f = event['failure']
client.captureException((f.type, f.value, f.getTracebackObject()))
log.addObserver(logToSentry)