Middleware that makes a request GUID available from anywhere and injects it into your logs.
Project description
GUID injection for Django
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 with a django-crequest approach.
Changelog
0.2.0 - 2019-12-21
Features
Header name and header GUID validation can be specified through Django settings.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-guid-0.2.2.tar.gz.
File metadata
- Download URL: django-guid-0.2.2.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08d487bd626817cd834608a109f2dae31ede5783dad275244f554467f99937da
|
|
| MD5 |
96164c8878328b44600fb8d1e25774e0
|
|
| BLAKE2b-256 |
11dff4b8ff6d161fca82d4e348435b7a4afce19ed1f3fcb70a0d7d8429d6d34f
|
File details
Details for the file django_guid-0.2.2-py3-none-any.whl.
File metadata
- Download URL: django_guid-0.2.2-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c54074e2aa32e28f8a4634c1ccddf9bf4b784a1f77ebd78212889f31f3d40a4
|
|
| MD5 |
225090c7c05e10871d5913a33e94fbaa
|
|
| BLAKE2b-256 |
03c5249eddcfb2c19ebfd08fc37ae163833e36421ffd656ca657b63e0a04bf27
|