Django Loguru 1.0.3 | Coderz Repository

django-loguru 1.0.3

Last updated:

0 purchases

django-loguru 1.0.3 Image
django-loguru 1.0.3 Images

Free

Languages

Categories

Add to Cart

Description:

djangologuru 1.0.3

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


Requirements
Installation
Settings
License


Requirements

Python >= 3.7
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.

DJANGO_LOGGING_MIDDLEWARE = {
'DEFAULT_FORMAT': True,
'MESSAGE_FORMAT': "<b><green>{time}</green> <cyan>{message}</cyan></b>",
'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

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

License
MIT-License

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product: (if this is empty don't purchase this product)

Customer Reviews

There are no reviews.