Skip to main content

Django python exception model, admin, logging handler, middleware and excepthook

Project description

Installation

$ pip install django-exception

settings.py

INSTALLED_APPS+=['django_exception']

migrate

$ python manage.py migrate

Models/tables

model table columns/fields
ExceptionModel django_exception id,module,filename,lineno,exc_class,exc_message,exc_traceback,timestamp

Examples

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 - log all exceptions

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-exception-1.0.0.tar.gz (3.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page