A prettier way to see Django requests while developing

Overview

django-rich-logging

A prettier way to see Django requests while developing.

PyPI PyPI - Downloads GitHub Sponsors

πŸ“– Complete documentation: https://django-rich-logging.readthedocs.io

πŸ“¦ Package located at https://pypi.org/project/django-rich-logging/

⭐ Features

  • live-updating table of all requests while developing

demo of django-rich-logging

Installation

poetry add django-rich-logging OR pip install django-rich-logging

Configuration

# settings.py

# other settings here

LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    "handlers": {
        "django_rich_logging": {
            "class": "django_rich_logging.logging.DjangoRequestHandler",
            "level": "INFO",
        },
    },
    "loggers": {
        "django.server": {"handlers": ["django_rich_logging"], "level": "INFO"},
        "django.request": {"level": "CRITICAL"},
    },
}

# other settings here

Read all of the documentation at https://django-rich-logging.readthedocs.io.

You might also like...
Django project starter on steroids: quickly create a Django app AND generate source code for data models + REST/GraphQL APIs (the generated code is auto-linted and has 100% test coverage).

Create Django App πŸ’› We're a Django project starter on steroids! One-line command to create a Django app with all the dependencies auto-installed AND

django-quill-editor makes Quill.js easy to use on Django Forms and admin sites
django-quill-editor makes Quill.js easy to use on Django Forms and admin sites

django-quill-editor django-quill-editor makes Quill.js easy to use on Django Forms and admin sites No configuration required for static files! The ent

A Django chatbot that is capable of doing math and searching Chinese poet online. Developed with django, channels, celery and redis.

Django Channels Websocket Chatbot A Django chatbot that is capable of doing math and searching Chinese poet online. Developed with django, channels, c

A handy tool for generating Django-based backend projects without coding. On the other hand, it is a code generator of the Django framework.
A handy tool for generating Django-based backend projects without coding. On the other hand, it is a code generator of the Django framework.

Django Sage Painless The django-sage-painless is a valuable package based on Django Web Framework & Django Rest Framework for high-level and rapid web

A beginner django project and also my first Django project which involves shortening of a longer URL into a short one using a unique id.

Django-URL-Shortener A beginner django project and also my first Django project which involves shortening of a longer URL into a short one using a uni

Dockerizing Django with Postgres, Gunicorn, Nginx and Certbot. A fully Django starter project.

Dockerizing Django with Postgres, Gunicorn, Nginx and Certbot πŸš€ Features A Django stater project with fully basic requirements for a production-ready

pytest-django allows you to test your Django project/applications with the pytest testing tool.

pytest-django allows you to test your Django project/applications with the pytest testing tool.

APIs for a Chat app. Written with Django Rest framework and Django channels.
APIs for a Chat app. Written with Django Rest framework and Django channels.

ChatAPI APIs for a Chat app. Written with Django Rest framework and Django channels. The documentation for the http end points can be found here This

django-dashing is a customisable, modular dashboard application framework for Django to visualize interesting data about your project. Inspired in the dashboard framework Dashing
django-dashing is a customisable, modular dashboard application framework for Django to visualize interesting data about your project. Inspired in the dashboard framework Dashing

django-dashing django-dashing is a customisable, modular dashboard application framework for Django to visualize interesting data about your project.

Comments
  • Display log time

    Display log time

    Summary

    This PR adds an extra column to the rich Console output for displaying the time.

    Changes

    πŸ’‘ In order to display a time, the logging handler needs a formatter that specifies a datefmt. This is needed so that the formatter can call formatTime, and we use that value to display!

    • Have DjangoRequestHandler.__init__ set a default formatter if none is passed in, else use passed in formatter
    • Have DjangoRequestHandler.emit call formatTime on its formatter and adds extra column to log output
    • Adds DjangoRequestHandler.__init__ tests πŸ§ͺ

    Testing

    1. Default formatter: Run the example project to see the default formatter at work! Time format will be HH:MM:SS
    2. Custom formatter: Add one of the pre-defined formatter to the django_rich_logging handler here. Time format will be whatever the formatter's datefmt setting is.
      • For example if you add "formatter": "verbose",, the time format will be YYYY-MM-DD HH:MM:SS

    Notes, Questions, & Follow-up

    • Modify README to include note about optionally passing a formatter to the django_rich_logging handler
    • Should the tests check for the cell content?
      • current tests does minimal checking for the Method and text color
      • time checking would require something like freezegun?
    • Update gif?
    opened by sjbitcode 1
  • recommended config doesn't output logger.debug()

    recommended config doesn't output logger.debug()

    I have this configuration

    LOGGING = {
        "version": 1,
        "disable_existing_loggers": False,
        "filters": {
            "require_debug_false": {
                "()": "django.utils.log.RequireDebugFalse",
            },
            "require_debug_true": {
                "()": "django.utils.log.RequireDebugTrue",
            },
        },
        "handlers": {
            "console": {
                "class": "logging.StreamHandler",
            },
            "rich_console": {
                "class": "django_rich_logging.logging.DjangoRequestHandler",
                "filters": ["require_debug_true"],
            },
        },
        "loggers": {
            "django.server": {
                "handlers": ["rich_console"],
                "level": "INFO",
            },
            "django.request": {"level": "CRITICAL"},
        },
    }
    

    but in another part of the code, when I have this, I get no output.

    import logging
    
    logger = logging.getLogger(__name__)
    
    class SomeClass:
        def something(self):
            logger.debug('TEST')
    

    but no output happens. if I change it to logger.warning() I see it in the console. How can I get this to work. I have tried a myriad of different settings and nothing seems to work.

    opened by autoferrit 3
  • `runserver_rich` management command

    `runserver_rich` management command

    • sub-class django.core.management.commands.runserver.Command
    • Automatically configure logging settings
    • redirect output to live.console or console status messages?
    opened by adamghill 0
Owner
Adam Hill
Just a normal dev trying to make the world a better place.
Adam Hill
Log and View requests made on Django

Django Request Viewer Log and view requests made on your Django App Introduction Recently, @ichtrojan and @toniastro released horus, a request logger

Akere Mukhtar 26 May 29, 2022
Book search Django web project that uses requests python library and openlibrary API.

Book Search API Developer: Vladimir Vojtenko Book search Django web project that uses requests python library and openlibrary API. #requests #openlibr

null 1 Dec 8, 2021
Django URL Shortener is a Django app to to include URL Shortening feature in your Django Project

Django URL Shortener Django URL Shortener is a Django app to to include URL Shortening feature in your Django Project Install this package to your Dja

Rishav Sinha 4 Nov 18, 2021
Django API that scrapes and provides the last news of the city of Carlos Casares by semantic way (RDF format).

"Casares News" API Api that scrapes and provides the last news of the city of Carlos Casares by semantic way (RDF format). Usage Consume the articles

AndrΓ©s Milla 6 May 12, 2022
A middleware to log the requests and responses using loguru.

Django Loguru The extension was based on another one and added some extra flavours. One of the biggest problems with the apps is the logging and that

Tiago Silva 9 Oct 11, 2022
Meta package to combine turbo-django and stimulus-django

Hotwire + Django This repository aims to help you integrate Hotwire with Django ?? Inspiration might be taken from @hotwired/hotwire-rails. We are sti

Hotwire for Django 31 Aug 9, 2022
django-reversion is an extension to the Django web framework that provides version control for model instances.

django-reversion django-reversion is an extension to the Django web framework that provides version control for model instances. Requirements Python 3

Dave Hall 2.8k Jan 2, 2023
Django-environ allows you to utilize 12factor inspired environment variables to configure your Django application.

Django-environ django-environ allows you to use Twelve-factor methodology to configure your Django application with environment variables. import envi

Daniele Faraglia 2.7k Jan 7, 2023
Rosetta is a Django application that eases the translation process of your Django projects

Rosetta Rosetta is a Django application that facilitates the translation process of your Django projects. Because it doesn't export any models, Rosett

Marco Bonetti 909 Dec 26, 2022
Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.

Cookiecutter Django Powered by Cookiecutter, Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly. Documentati

Daniel Feldroy 10k Dec 31, 2022