Skip to main content

Django Decorator of Logging Request Params

Project description

Django Decorator of Logging Request Params

Installation

pip install django-logit

Usage

from logit import logit

@logit
def xxx(request):
    xxx

Settings.py

# logger setting
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
        },
        'simple': {
            'format': '%(levelname)s %(message)s'
        },
    },
    'handlers': {
        'logit': {
            'level': 'DEBUG',
            'class': 'logging.FileHandler',
            'filename': '/tmp/logit.log',
            'formatter': 'verbose'
        },
    },
    'loggers': {
        'logit': {
            'handlers': ['logit'],
            'level': 'DEBUG',
            'propagate': True,
        },
    },
}

Use RotatingFileHandler to support rotation of disk log files.

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
        },
        'simple': {
            'format': '%(levelname)s %(message)s'
        },
    },
    'handlers': {
        'logit': {
            'level': 'DEBUG',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': '/tmp/logit.log',
            'maxBytes': 15728640,  # 1024 * 1024 * 15B = 15MB
            'backupCount': 10,
            'formatter': 'verbose',
        },
    },
    'loggers': {
        'logit': {
            'handlers': ['logit'],
            'level': 'DEBUG',
            'propagate': True,
        },
    },
}

Use TimedRotatingFileHandler to support rotation of disk log files at certain timed intervals.

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
        },
        'simple': {
            'format': '%(levelname)s %(message)s'
        },
    },
    'handlers': {
        'logit': {
            'level': 'DEBUG',
            'class': 'logging.handlers.TimedRotatingFileHandler',
            'filename': '/tmp/logit.log',
            'when': 'midnight',
            'backupCount': 10,
            'formatter': 'verbose',
        },
    },
    'loggers': {
        'logit': {
            'handlers': ['logit'],
            'level': 'DEBUG',
            'propagate': True,
        },
    },
}

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-logit-1.0.2.tar.gz (1.8 kB view details)

Uploaded Source

Built Distribution

django_logit-1.0.2-py2.py3-none-any.whl (3.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-logit-1.0.2.tar.gz.

File metadata

File hashes

Hashes for django-logit-1.0.2.tar.gz
Algorithm Hash digest
SHA256 b6bff4b10ce0d7180902f5e05e3d7d4bd5a6984d5000e2c7c441d160c2c55e4e
MD5 fb626dc08fe1dd111a8d6c1a09a55ce9
BLAKE2b-256 c50b7490f3101d3470c4b0dda2a0089c861627052d2b0c686b88caf616f5bdc5

See more details on using hashes here.

File details

Details for the file django_logit-1.0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_logit-1.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bb70544ec780a05e48d38ac0f5ba7cba74d0bd212bac4418591afecc68c8d3cf
MD5 f66e42470d7541802dad0a00a11dfb71
BLAKE2b-256 17b80d4b068fc343cf60ae24919fa9e81e86092db48fcb4522d7e79161ecd893

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