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.5.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

django_logit-1.0.5-py2.py3-none-any.whl (3.8 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for django-logit-1.0.5.tar.gz
Algorithm Hash digest
SHA256 69a91dc76f791110d501fc2cc042df919200aad54adbc5cbd55192ee155bc180
MD5 0c4d571321d8c111256148d3685a1bca
BLAKE2b-256 a9efff22315cc943641d00a996d7390c8e1188ecce2279edf020ab77491e2e3c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_logit-1.0.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4c62c5c116cdcd78207d179c2651c30ac4311ce236539089eeb573c7d7025f8a
MD5 928f81bf0fd38a43ea279738f60b351e
BLAKE2b-256 3206291eca4b378974419866cf19d704434409c58db40e5597da1ab6e4a743b6

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