Created
September 20, 2012 14:03
-
-
Save felipe-prenholato/3756123 to your computer and use it in GitHub Desktop.
Snippet to create errors with complete info in sentry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, logging | |
exc_info = sys.exc_info() | |
# this is important to get request info like url, browser, etc. | |
data = sentry_cli.get_data_from_request(request) | |
# and this to say what level of msg (error in case) and module of app current app | |
data.update({ | |
'level': logging.ERROR, | |
'logger': __name__, | |
}) | |
# than in extra you put all additional info u want. | |
extra = { | |
'extra': { | |
'record': record, | |
'row': row, | |
'col': col, | |
'field info': field, | |
}, | |
} | |
# send, and get the error id | |
sentry_msg_id = sentry_cli.get_ident( | |
sentry_cli.captureException(exc_info=exc_info, | |
data=data, **extra) | |
) | |
# clean garbage | |
del exc_info | |
del extra | |
del data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment