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.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41cbd02a1d63f5c3fd14d854dcf23dbab84aa34919a1b4879a198302ba1321d3 |
|
MD5 | 6664194e217f45c08708bbc89b33ba73 |
|
BLAKE2b-256 | a55f671eca0baf069462abc4c4fee5b07aee5260cfca6c58ec93dee6a8eeba44 |
Close
Hashes for django_db_log_plugin-0.1.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d220f069269ec41aa4ded3354fe59118c528c6a8833b651077672cabb4550fe |
|
MD5 | 03490a1052ca1bc035ee785e2a0b26e4 |
|
BLAKE2b-256 | b0d8365f2c4d55d49433bd0a64f37862734db57049e2ab2ce1975b19b4981781 |