Skip to main content

Log and view requests and exceptions made on your Django app

Project description

Django Request Viewer

Log and view requests and exceptions made on your Django App

Updates 17th, January 2022

  • Adds Exception logger
  • Cleaned up the code

Introduction

Screenshot 2021-03-29 at 09 30 17

Recently, @ichtrojan and @toniastro released horus, a request logger and viewer for Go. Then I felt the need for something like that for the Django community.

Installation

Install using pip

pip install django-request-viewer

Usage

Add 'request-viewer' to your INSTALLED_APPS in settings.py.

INSTALLED_APPS = [
    ...
    'request_viewer',
    ...
]

Add 'request_viewer.middleware.RequestViewerMiddleware' to your MIDDLEWARE list in settings.py.

MIDDLEWARE = [
    ...
    'request_viewer.middleware.RequestViewerMiddleware',
    ...
]  
To log exceptions, add

Add 'request_viewer.middleware.ExceptionMiddleware' to your MIDDLEWARE list in settings.py.

MIDDLEWARE = [
    ...
    'request_viewer.middleware.ExceptionMiddleware',
    ...
]  

Add 'request-viewer' to your main urls.py

urlpatterns = [
  ...
  path('logs/', include('request_viewer.urls'))
  ...
]

Run migrations, python manage.py migrate request_viewer

OPTIONAL

Add REQUEST_VIEWER dictionary to your settings.py.

LIVE_MONITORING: Default: True, False to pause monitoring.

WHITELISTED_PATH: Default: [], This is a list of paths to be excluded when monitoring

{
  "LIVE_MONITORING": True,
  "WHITELISTED_PATH": ['admin/']
}

Note: Media url, Static url and request-viewer url are automatically excluded.

Start your server and head to http://localhost:8000/logs/request-viewer to view requests

Head to http://localhost:8000/logs/request-viewer/exceptions to view exceptions

View your request logs.

Screenshot 2021-03-29 at 09 30 33

Contribute

Well, no big drama, fork the repo and make pull requests, easy-peasy, right?

TODO

  • JSON export
  • Caching
  • Create an African unicorn
  • Buy a yacht

Credits

Follow me (I am not boring, I promise)

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-request-viewer-1.0.3.tar.gz (17.2 kB view hashes)

Uploaded Source

Built Distribution

django_request_viewer-1.0.3-py3-none-any.whl (26.3 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