Django Python 异常模型、管理、日志处理程序、中间件和excepthook
项目描述
安装
$ pip install django-exception
settings.py
INSTALLED_APPS+=['django_exception']
migrate
$ python manage.py migrate
模型/表
模型 | 表 | 列/字段 |
---|---|---|
ExceptionModel |
django_exception |
id,module,filename,lineno,exc_class,exc_message,exc_traceback,timestamp |
示例
settings.py
LOGGING = {
"version": 1,
"handlers": {
"console": {
"level": "DEBUG",
"class": "logging.StreamHandler",
},
"django_exception": {
"level": "ERROR",
"class": "django_exception.ExceptionLogHandler",
}
},
"root": {
"handlers": ["console", "django_exception"],
"level": "DEBUG",
},
"loggers": {
"django_exception": {
"level": "ERROR",
"handlers": ["django_exception"],
"propagate": True,
},
},
}
MIDDLEWARE = [
"django_exception.middleware.ExceptionMiddleware",
]
sys.excepthook
- 记录所有异常
import sys
import django_exception
def excepthook(exc_type, exc_message, tb):
django_exception.excepthook(exc_type, exc_message, tb)
raise exc_type(exc_message)
sys.excepthook = excepthook
项目详情
关闭
django-exception-1.0.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 714319944b52b53d4a26fbd1e4f5761482a16e96925f3e28ae43abdb46da7f52 |
|
MD5 | 498fc0880e55e887499892e03a81c16c |
|
BLAKE2b-256 | c8237de4a878da04e0fe1e3299b435263d9203bd78aef43d46e50924d9291941 |