Skip to main content

A package for logging all requests

Project description

Logging

Middleware для логирования request запросов на endpoint.

Quick start

  1. Add "django_logging_requests" to your INSTALLED_APPS setting like this::

    INSTALLED_APPS = [ ... 'django_logging_requests', ]

  2. Create logging handlers with LOGGING name within settings.py. The middleware uses handlers with names: info_logger and error_logger .

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'standard': {
            'format': '{levelname} {asctime} \nDETAILS: {message}\n\n',
            'style': '{',
        }
    },
    'handlers': {
        'console': {
            'class': 'logging.StreamHandler',
            'formatter': 'standard',
            'stream': 'ext://sys.stdout'
        },
        'error': {
            'level': 'ERROR',
            'class': 'logging.FileHandler',
            'filename': BASE_DIR / 'logs' / 'backend.error.log',
            'formatter': 'standard'
        },
        'warning': {
            'level': 'WARNING',
            'class': 'logging.FileHandler',
            'filename': BASE_DIR / 'logs' / 'backend.warning.log',
            'formatter': 'standard'
        },
        'info': {
            'level': 'INFO',
            'class': 'logging.FileHandler',
            'filename': BASE_DIR / 'logs' / 'backend.info.log',
            'formatter': 'standard'
        },
    },
    'loggers': {
        'info_logger': {
            'handlers': ['info'],
            'level': 'INFO'
        },
        'warning_logger': {
            'handlers': ['warning'],
        },
        'error_logger': {
            'handlers': ['error'],
        },
    }
}
  1. Create LOGGING_SERVER_NAME withing settings.py. The middleware uses this variable as server name key in every log message.
LOGGING_SERVER_NAME = 'server name'
  1. Add a middleware class to listen in on responses

MIDDLEWARE = [ ..., "django_logging_requests.middleware.LoggingMiddleware", ..., ]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_logging_requests-1.0.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

django_logging_requests-1.0.2-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file django_logging_requests-1.0.2.tar.gz.

File metadata

File hashes

Hashes for django_logging_requests-1.0.2.tar.gz
Algorithm Hash digest
SHA256 cdada15adef363de0410ec44dd0be001c23a84f7d6e38344e3ca637851a2ab0c
MD5 a663297e42b0ef4729cf0a02451c5ba9
BLAKE2b-256 6c193e27a204268742b652313dfe9b99d39b2f78eaf4a6c8794c5390ecb6cf1d

See more details on using hashes here.

File details

Details for the file django_logging_requests-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_logging_requests-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 92eb2e9ee1bedf12291389f07334c170e40f5f15237b901a7715e487706ce4a3
MD5 64a464a2ba8c06f5a0f185144baa0491
BLAKE2b-256 30d9bc161ea80bded2dcc8f222b3b7487ab88787839472fece70aa05052c5f08

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page