Skip to main content

Custom DB Log Handler for Django Projects.

Project description

https://badge.fury.io/py/django-db-log-plugin.svg https://travis-ci.org/eduarde/django-db-log.svg?branch=master https://codecov.io/gh/eduarde/django-db-log/branch/master/graph/badge.svg https://img.shields.io/pypi/wheel/django-db-log-plugin.svg

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_db_log_plugin-0.1.3.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_db_log_plugin-0.1.3-py2.py3-none-any.whl (11.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django_db_log_plugin-0.1.3.tar.gz.

File metadata

  • Download URL: django_db_log_plugin-0.1.3.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for django_db_log_plugin-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1b1518fa27dee83dd0ae72d5562aa0bb015eef37254416f16586411124c8968e
MD5 ae4495290cd56982269efd4df8e7851c
BLAKE2b-256 debab78ac0eb7e92e567831c0d10a6014ed0c6ebb6be55739db280584a9340d3

See more details on using hashes here.

File details

Details for the file django_db_log_plugin-0.1.3-py2.py3-none-any.whl.

File metadata

  • Download URL: django_db_log_plugin-0.1.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using 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

File hashes

Hashes for django_db_log_plugin-0.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ad4a2d092ea59f7b73f6222ba5e0f2768fd66a4d5b096735c57c3f5efb347e9b
MD5 e70acfbb9b73add3523cdf81cea10b00
BLAKE2b-256 19a17ecbbb3c61f9bf15acbde2cb97ceb04b747750bec0c91b9ee0433e7a31fb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page