Middleware that makes a request GUID available from anywhere and injects it into your logs.
Project description
Django GUID attaches a GUID to the local thread of a request. The GUID is accessible from anywhere within the application throughout a request, making it possible to inject the GUID into the logs.
Free software: BSD License
Homepage: https://github.com/JonasKs/django-guid
Documentation: Incoming
Installation
Python package:
pip install django-guid
In your project’s settings.py add these settings:
Add the middleware to the middleware (To ensure the GUID to be injected in all logs, put it on top)
MIDDLEWARE = [
'django_guid.middleware.GuidMiddleware',
...
]
Add a filter to your LOGGING:
LOGGING = {
'filters': {
'correlation_id': {
'()': 'django_guid.log_filters.CorrelationId'
}
}
}
and put that filter in your handler:
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'formatter': 'medium',
'filters': ['correlation_id'],
}
}
and lastly make sure we add it to the format:
'medium': {
'format': '%(levelname)s %(asctime)s [%(correlation_id)s] %(name)s %(message)s'
}
Inspired by django-log-request-id and django-crequest
2019-12-20
Initial release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_guid-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eda81a66ddfd79e0bda4831ffa9111a9c6528a4d3135d0f4f99a42893b0d8eab |
|
MD5 | f3e39cefd2fee8ac2163cf00c38874b8 |
|
BLAKE2b-256 | a52e90b7e5b141eaa0fc0431280ae0538efed656390a663461a98aacb0854bcc |