Skip to main content

Request ID Django Log

Build Status Maintainability Test Coverage Coverage Status PyPI version Code style: black Downloads Downloads Downloads Say Thanks!

Install

pip install request-id-django-log

Update your INSTALLED_APPS and MIDDLEWARE

INSTALLED_APPS = [
    ...
    "request_id_django_log",
]
MIDDLEWARE = [
    ...
    "request_id_django_log.middleware.RequestIdDjangoLog",
]

Configure

The following options are used by this library:

REQUEST_ID_CONFIG = {
    "REQUEST_ID_HEADER": "HTTP_X_REQUEST_ID",
    "GENERATE_REQUEST_ID_IF_NOT_FOUND": True,
    "RESPONSE_HEADER_REQUEST_ID": "HTTP_X_REQUEST_ID",
}
  • REQUEST_ID_HEADER is the header name which will hold the received request_id. This must be used when another system is responsible for generating the request_ids and sending them to your django application.
  • GENERATE_REQUEST_ID_IF_NOT_FOUND If set to true, a new request_id will be generated if none was previously supplied.
  • RESPONSE_HEADER_REQUEST_ID sets the name of the response header which will hold the value of the request_id.

With this configuration if the request have the header X-REQUEST-ID the library will use this header value.

Logs

If you want your logs to have the request id, add the following lines to your logging dictionary configuration:

LOGGING = {
    ...
    "filters": {"request_id": {"()": "request_id_django_log.filters.RequestIDFilter"}},
    "formatters": {
        "standard": {
            ...
            "format": "%(levelname)-8s [%(asctime)s] [%(request_id)s] %(name)s: %(message)s",
        },
        ...
    },
    "handlers": {
        "console": {
            ...
            "filters": ["request_id"],
            ...
        }
    },
    "loggers": {
        "": {"level": "INFO", "handlers": ["console"]},
        ...
    },
}

Supported Versions

  • python 2.7 with Django 1.8, 1.9 and 1.11
  • python 3.5, 3.6 and 3.7 with Django 1.8, 1.9, 1.11, 2.0, 2.1, 2.2 and 3.0

Metadata

Release files for request-id-django-log 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for request-id-django-log 0.2.0
File Size Uploaded Provenance Actions
request_id_django_log-0.2.0.tar.gz 5.6 kB Without provenance Details for request_id_django_log-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for request-id-django-log 0.2.0
File Interpreter ABI Platform Actions
request_id_django_log-0.2.0-py3-none-any.whl Python 3 none any Details for request_id_django_log-0.2.0-py3-none-any.whl

Total release size: 13.3 kB

Release files / request_id_django_log-0.2.0.tar.gz

Download URL request_id_django_log-0.2.0.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9a4ee69a5d5f70b8a34938a99de1c4c0878a44f8c3c84d2ab85195b1d15563d9
BLAKE2b-256 checksum
How to use checksums
d99624c893dca377a8525f0e38d32211fb8887a66f3b8ccdf7fc91f298a81c97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.4

Release files / request_id_django_log-0.2.0-py3-none-any.whl

Download URL request_id_django_log-0.2.0-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cd860ebede18c8dace21ea565282521b44ea3f91a5c819baf4adf1d3db8d725c
BLAKE2b-256 checksum
How to use checksums
9bbc013a294c137453897f6fff09c012dc9235db101830c5ec8dbf800ea50edd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.4

Security for request-id-django-log 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page