与哨兵相结合的三位一体错误处理器
sanic-sentry-error-handler的Python项目详细描述
Sanic Web服务器的Sentry错误处理程序
要求
- python>;=3.5
安装
sanic sentry错误处理程序应使用pip安装:
pip install sanic-sentry-error-handler
用法
sentry\u dsn-应用程序的sentry dsn
首先,我们将设置一个sanic应用程序:
>>>fromsanicimportSanic>>>fromsanic_sentryimportSanicSentryErrorHandler>>>app=Sanic(__name__)>>>app.error_handler=SanicSentryErrorHandler('http://public:secret@example.com/1')
如果应用程序使用Sanic exception handling views,则可以考虑使用decorator来截取异常。
>>>fromsanicimportresponse,Sanic>>>fromsanic_sentryimportSanicSentryErrorHandler>>>>>>sentry_client=SanicSentryErrorHandler('http://public:secret@example.com/1')>>>app=Sanic(__name__)>>>>>>>>>@app.exception([Exception,])>>>@sentry_client.intercept_exception>>>defhandle_exception_500(request,exception):>>>returnresponse.json({"description":"Internal Server Error"},status=500)