将Django异常报告给Google Stackdriver错误报告
项目描述
dj-cloud-error: Django Google Cloud Error Reporting
将任何Django站点的异常报告给Google Cloud Stackdriver Error Reporting
免费软件:MIT许可证
特性
将任何Django站点的异常报告给Google Cloud Stackdriver Error Reporting
可选的django-ipware依赖项,用于记录IP地址
快速入门
配置您的应用程序以使用Google Cloud项目
按照https://cloud.google.com/error-reporting/docs/setup/python 启用错误报告api
设置所需的Google IAM凭证 - 例如,将环境变量GOOGLE_APPLICATION_CREDENTIALS设置为服务帐户JSON文件的路径,该帐户具有“错误写入者”权限。
安装包
pip install dj_cloud_error
通过在Django项目的根目录下的urls.py文件中设置handler500来启用提供的异常处理器。
# in myproject/urls.py import dj_cloud_error handler500 = dj_cloud_error.handler500
注意:只有在django设置中DEBUG = False时才使用handler500。
设置
要禁用错误报告(例如在您的CI/CD环境中),请将以下内容添加到您的django设置中
# in myproject/settings/test.py CLOUD_ERROR_REPORTING_DISABLED = True
要配置错误显示的名称,请将以下内容添加到您的django设置中
CLOUD_ERROR_REPORTING_SERVICE_NAME = "myservice" # defaults to "python"
可选额外功能
如果已安装django-ipware,则将其用于记录客户端IP地址,安装方法如下
pip install dj_cloud_error[ip]
致谢
此包是用Cookiecutter和audreyr/cookiecutter-pypackage项目模板创建的。
历史
0.1.0 (2019-10-01)
首次发布在PyPI。