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.
Metadata
Release files for django-db-log-plugin 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_db_log_plugin-0.1.3.tar.gz | 10.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_db_log_plugin-0.1.3-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 21.6 kB
Release files / django_db_log_plugin-0.1.3.tar.gz
| Download URL | django_db_log_plugin-0.1.3.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1b1518fa27dee83dd0ae72d5562aa0bb015eef37254416f16586411124c8968e
|
|
BLAKE2b-256 checksum How to use checksums |
debab78ac0eb7e92e567831c0d10a6014ed0c6ebb6be55739db280584a9340d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.10
|
Release files / django_db_log_plugin-0.1.3-py2.py3-none-any.whl
| Download URL | django_db_log_plugin-0.1.3-py2.py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
ad4a2d092ea59f7b73f6222ba5e0f2768fd66a4d5b096735c57c3f5efb347e9b
|
|
BLAKE2b-256 checksum How to use checksums |
19a17ecbbb3c61f9bf15acbde2cb97ceb04b747750bec0c91b9ee0433e7a31fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.10
|