django-logit
Django Decorator of Logging Request Params/Response Content
Installation
pip install django-logit
Usage
from django_logit import logit
@logit
def xxx(request):
xxx
@logit(body=True, res=True)
def ooo(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,
},
},
}
ConcurrentLogHandler:
Use RotatingFileHandler/TimedRotatingFileHandler ``Logs Missing`` when host in uwsgi with multiple process
Use ConcurrentLogHandler Instead
Concurrent logging handler (drop-in replacement for RotatingFileHandler) Python 2.6+.
This module provides an additional log handler for Python’s standard logging package (PEP 282). This handler will write log events to log file which is rotated when the log file reaches a certain size. Multiple processes can safely write to the same log file concurrently.
Installation: pip install ConcurrentLogHandler
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.ConcurrentRotatingFileHandler',
'filename': '/tmp/logit.log',
'maxBytes': 15728640, # 1024 * 1024 * 15B = 15MB
'backupCount': 10,
'formatter': 'verbose',
},
},
'loggers': {
'logit': {
'handlers': ['logit'],
'level': 'DEBUG',
'propagate': True,
},
},
}
RotatingFileHandler:
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,
},
},
}
TimedRotatingFileHandler:
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,
},
},
}
Metadata
Release files for django-logit 1.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-logit-1.1.4.tar.gz | 2.7 kB | Without provenance | Details for django-logit-1.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_logit-1.1.4-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for django_logit-1.1.4-py2.py3-none-any.whl |
Total release size: 5.9 kB
Release files / django-logit-1.1.4.tar.gz
| Download URL | django-logit-1.1.4.tar.gz |
|---|---|
| Size | 2.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7896fdd5e8260cfab0bdcad8d10f337b10ec246c924f8aef3a9244efe19476cb
|
|
BLAKE2b-256 checksum How to use checksums |
b3edac6e61968e4ce448a4ad8e9a00ea80ad09c7f6e4418a047a079e5b9315d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.2
|
Release files / django_logit-1.1.4-py2.py3-none-any.whl
| Download URL | django_logit-1.1.4-py2.py3-none-any.whl |
|---|---|
| Size | 3.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
441f2443a4daf51228158423b3d4674897ad0718f1211fe0bc754a20fed418dc
|
|
BLAKE2b-256 checksum How to use checksums |
7a4557b317759f43d0037a4cf8cfbffecaf11dd25f3bd55fbe7dc757fb947c3b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.2
|
Security for django-logit 1.1.4
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.