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.
Features
Capture logs and save them in database.
Examine logs in the administration page of the website.
Job scheduler to delete old logs from the database.
Quickstart
Install Django DB Log:
pip install django-db-log-plugin
Add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'django_apscheduler',
'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:
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
Hashes for django_db_log_plugin-0.1.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b1518fa27dee83dd0ae72d5562aa0bb015eef37254416f16586411124c8968e |
|
MD5 | ae4495290cd56982269efd4df8e7851c |
|
BLAKE2b-256 | debab78ac0eb7e92e567831c0d10a6014ed0c6ebb6be55739db280584a9340d3 |
Hashes for django_db_log_plugin-0.1.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad4a2d092ea59f7b73f6222ba5e0f2768fd66a4d5b096735c57c3f5efb347e9b |
|
MD5 | e70acfbb9b73add3523cdf81cea10b00 |
|
BLAKE2b-256 | 19a17ecbbb3c61f9bf15acbde2cb97ceb04b747750bec0c91b9ee0433e7a31fb |