Skip to main content

Exception Logger with AI Suggestions for Django

Project description

ExceptBot: Django Exception Logger with AI Suggestions for Fixing

ExceptBot is a simple Django middleware application that captures and logs exceptions that occur within your Django project. With this middleware, developers can quickly view exceptions, the files and lines where they originated, and details about the user that triggered them.

Features

  • Automatically logs exceptions, including:
    • The Python Code where the exception occurred
    • The full stack trace
    • the line of code that caused the issue
    • URL path, Exception type, timestamp
    • User (if authenticated) that triggered the exception
  • Gets AI Suggestions
    • Sends all relevant info to ChatGPT API:
      • Stack trace
      • Source code producing the exception
      • line causing the exception
  • Superuser-restricted views to:
    • View a list of unresolved exceptions
    • Mark exceptions as resolved
    • View detailed information for each exception
    • Tracks which superuser resolved an exception and when

Installation

  1. Install the ExceptBot library
pip3 install exceptbot
  1. Add 'ExceptBot' to INSTALLED_APPS in your project's settings.py:
INSTALLED_APPS = [
    # ...
    'exceptbot',
    # ...
]
  1. Include the middleware in the MIDDLEWARE list in your settings.py:
MIDDLEWARE = [
    # ...
    'exceptbot.middleware.ExceptBotMiddleware',
    # ...
]
  1. Include the ExceptBot URLs in your project's urls.py:
from django.urls import path, include

urlpatterns = [
  # ...
  path('exceptbot/', include('exceptbot.urls')),
  # ...
]

Run migrations to create the necessary database tables and set up static files

$ python3 manage.py migrate exceptbot
$ python3 manage.py collectstatic --no-input

Usage

Once integrated into your Django project:

  • Any exception that occurs will be automatically logged by the middleware.
  • Superusers can navigate to /exceptbot/ to view a list of unresolved exceptions.
  • Click on an exception to view its detailed information.
  • Superusers can mark exceptions as resolved, which will also record who resolved it and when.

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

exceptbot-1.0.2.tar.gz (225.8 kB view hashes)

Uploaded Source

Built Distribution

exceptbot-1.0.2-py3-none-any.whl (227.9 kB view hashes)

Uploaded Python 3

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