A middleware to log the requests and responses using loguru.

Related tags

Djangodjango-loguru
Overview

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 can be messy sometimes.

Since this serves as a middleware, it only depends on django (including django rest framework).

Documentation: https://tarsil.github.io/django-loguru/

Table of Contents


  1. Requirements
  2. Installation
  3. Settings
  4. License

Requirements

  1. Python >= 3.7
  2. Django >= 3.1

Installation

  • pip install django-loguru
  • Add django_loguru to INSTALLED_APPS settings.
INSTALLED_APPS = [
    ...
    'django_loguru'
]
  • Add DJANGO_LOGURU_MIDDLEWARE to your settings.
{time} {message} ", 'LOG_USER': False } ">
DJANGO_LOGGING_MIDDLEWARE = {
    'DEFAULT_FORMAT': True,
    'MESSAGE_FORMAT': "
    
     {time}
     
    
     {message}
    ",
    'LOG_USER': False
}
  • Add django_loguru.middleware.DjangoLoguruMiddleware as the very last in the list of MIDDLEWARE.

The logs should be now activated for every request/response of you application.

If you desire to override what is shown on the screen.

from django_loguru.middleware import DjangoLoguruMiddleware

class MyCustomMiddleware(DjangoLoguruMiddleware):

    def __call__(self, request):
        """
        Code to be executed on every request/response call.
        """
        logger.info(f"URL: {request.get_raw_uri()}")
        logger.info(f"Method: {request.method}")
        ...
        ...

Settings

  1. DEFAULT_FORMAT - Default True and it will use the default MESSAGE_FORMAT.
  2. MESSAGE_FORMAT - Sets the format of the log messages. Defaults to {time} {message} . More information about your options on loguru docs.
  3. LOG_POST - Default to False and it won't show POST data.
  4. LOG_PUT - Default to False and it won't show PUT data.
  5. LOG_PATCH - Default to False and it won't show PATCH data.
  6. LOG_DELETE - Default to False and it won't show DELETE data.
  7. LOG_USER - Default to True and tells which user did the request/response.

License

MIT-License

Owner
Tiago Silva
Entrepreneur, fully minded and dedicated software engineer with strong backend background and leadership skills.
Tiago Silva
Django StatusPage - App to display statuspage for your services

Django StatusPage - App to display statuspage for your services

Gorlik 1 Oct 27, 2021
Add Chart.js visualizations to your Django admin using a mixin class

django-admincharts Add Chart.js visualizations to your Django admin using a mixin class. Example from django.contrib import admin from .models import

Dropseed 22 Nov 22, 2022
Twitter Bootstrap for Django Form - A simple Django template tag to work with Bootstrap

Twitter Bootstrap for Django Form - A simple Django template tag to work with Bootstrap

tzangms 557 Oct 19, 2022
Django Girls Tutorial Workshop

Django Girls Tutorial Workshop A log of activities during the workshop. this is an H2 git remote add origin https://github.com/ahuimanu/django_girls_t

Jeffry Babb 1 Oct 27, 2021
django-idom allows Django to integrate with IDOM

django-idom allows Django to integrate with IDOM, a package inspired by ReactJS for creating responsive web interfaces in pure Python.

113 Jan 04, 2023
Актуальный сборник шаблонов для создания проектов и приложений на Django

О чем этот проект Этот репозиторий с шаблонами для быстрого создания Django проекта. В шаблоне проекта настроены следующий технологий: Django gunicorn

Denis Kustov 16 Oct 20, 2022
Django Advance DumpData

Django Advance Dumpdata Django Manage Command like dumpdata but with have more feature to Output the contents of the database from given fields of a m

EhsanSafir 7 Jul 25, 2022
File and Image Management Application for django

Django Filer django Filer is a file management application for django that makes handling of files and images a breeze. Contributing This is a an open

django CMS Association 1.6k Dec 28, 2022
Extensions for using Rich with Django.

django-rich Extensions for using Rich with Django. Requirements Python 3.6 to 3.10 supported. Django 2.2 to 4.0 supported. Are your tests slow? Check

Adam Johnson 88 Dec 26, 2022
Simply integrate Summernote editor with Django project.

django-summernote Summernote is a simple WYSIWYG editor. django-summernote allows you to embed Summernote into Django very handy. Support admin mixins

Summernote 936 Jan 02, 2023
E-Commerce Platform

Shuup Shuup is an Open Source E-Commerce Platform based on Django and Python. https://shuup.com/ Copyright Copyright (c) 2012-2021 by Shuup Commerce I

Shuup 2k Jan 07, 2023
Django REST Client API

Django REST Client API Client data provider API.

Ulysses Monteiro 1 Nov 08, 2021
webfest Django project @innovaccer

inno-doctor webfest Django project @innovaccer setup guide create new directory for project clone the repo with url into the directory make sure pytho

Rohit sahu 6 Oct 28, 2022
Hotwired/Turbo Django response helpers

This package provides helpers for server-side rendering of Hotwired/Turbo streams and frames. Disclaimer: the Hotwired/Turbo client libraries are, at

Hotwire for Django 66 Apr 07, 2022
A simple polling app made in Django and Bootstrap

DjangoPolls A Simple Polling app made with Django Instructions Make sure you have Python installed Step 1. Open a terminal Step 2. Paste the given cod

Aditya Priyadarshi 1 Nov 10, 2021
Python CSS/Javascript minifier

Squeezeit - Python CSS and Javascript minifier Copyright (C) 2011 Sam Rudge This program is free software: you can redistribute it and/or modify it un

Smudge 152 Apr 03, 2022
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
Basic implementation of Razorpay payment gateway 💳 with Django

Razorpay Payment Integration in Django 💥 In this project Razorpay payment gateway 💳 is integrated with Django by breaking down the whole process int

ScaleReal 12 Dec 12, 2022
A Django web application that allows you to be in the loop about everything happening in your neighborhood.

A Django web application that allows you to be in the loop about everything happening in your neighborhood. From contact information of different handyman to meeting announcements or even alerts.

Kennedy Ngugi Mwaura 3 Dec 11, 2022
✋ Auto logout a user after specific time in Django

django-auto-logout Auto logout a user after specific time in Django. Works with Python 🐍 ≥ 3.7, Django 🌐 ≥ 3.0. ✔️ Installation pip install django-a

Georgy Bazhukov 21 Dec 26, 2022