Custom DB Log Handler for Django Projects.
Project description
Custom DB Log Handler for Django Projects.
Documentation
The full documentation is at https://django-db-log.readthedocs.io.
Quickstart
Install Django DB Log:
pip install django-db-log-plugin
Add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'django_db_log',
...
)
Add Django DB Log’s URL patterns:
from django_db_log import urls as django_db_log_urls
urlpatterns = [
...
url(r'^', include(django_db_log_urls)),
...
]
Add the LOGGING configuration in the settings.py file.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '[%(asctime)s] %(levelname)s %(module)s.%(funcName)s %(lineno)d: %(message)s'
},
'simple': {
'format': ' %(levelname)s %(message)s',
},
},
'handlers': {
'log_db': {
'level': 'ERROR',
'class': 'django_db_log.handlers.DBHandler',
'model': 'django_db_log.models.ErrorLog',
'expiry': 86400,
'formatter': 'simple',
},
},
'loggers': {
'django': {
'handlers': ['log_db'],
'level': 'ERROR',
'propagate': False,
},
},
}
Add the following constants in your settings file. These will be used to determine the lookup days to delete old logs from db.
INTERVAL_SCHEDULER_JOB_SECONDS = 43200
GENERAL_LOGS_DELETE_DAYS = 2
INFO_LOGS_DELETE_DAYS = 2
DEBUG_LOGS_DELETE_DAYS = 2
ERROR_LOGS_DELETE_DAYS = 10
Run migrations
python manage.py migrate
Running Tests
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install tox (myenv) $ tox
Credits
Tools used in rendering this package:
TO DO
release on PyPI
create tags
History
0.1.0 (2018-08-29)
First release on PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django_db_log_plugin-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 465d2fa65771e80b5630afef440b35977a997939caed3b6ab43d8bae2330a56c |
|
MD5 | fd305ac3e47327b882315bfd5d687e02 |
|
BLAKE2b-256 | 9237dc577e951ff389feb4ab52d76735f04d839a63e8e9b03c64ffc1141cc1bf |
Close
Hashes for django_db_log_plugin-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6797c3adedfabe28c48ee7e81176cc3a657946d44172985c65396f0a97d77b7 |
|
MD5 | 2ee5597b62656ed0efc2c843e45dd806 |
|
BLAKE2b-256 | ad9917af5cdf57f35ab3d9fb3c3202c128bcd48436a37fb2b6f79da6743a94ef |