Skip to main content

Django logging in database

Project description

Disclaimer

Update from django-db-logger, due to inactivity of the original package.

Original readme

Django logging in database. For large projects please use Sentry

Screenshot

https://ciciui.github.io/django-db-logger/static/img/django-db-logger.png

Dependency

  • Django>=1.9
  • Python 2.7+/3.6+

License

MIT

Quick start

  1. Install
pip install django-db-logs
  1. Add “django_db_logs” to your INSTALLED_APPS setting like this
INSTALLED_APPS = (
    ...
    'django_db_logs',
)
  1. Add handler and logger to LOGGING setting like this
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
        },
        'simple': {
            'format': '%(levelname)s %(asctime)s %(message)s'
        },
    },
    'handlers': {
        'db_log': {
            'level': 'DEBUG',
            'class': 'django_db_logs.db_log_handler.DatabaseLogHandler'
        },
    },
    'loggers': {
        'db': {
            'handlers': ['db_log'],
            'level': 'DEBUG'
        }
    }
}
  1. Run python manage.py migrate to create django-db-logs models.
  2. Use django-db-logs like this
import logging
db_logs = logging.getLogger('db')

db_logs.info('info message')
db_logs.warning('warning message')

try:
    1/0
except Exception as e:
    db_logs.exception(e)

Options

  1. DJANGO_db_logs_ADMIN_LIST_PER_PAGE: integer. list per page in admin view. default 10
  2. DJANGO_db_logs_ENABLE_FORMATTER: boolean. Using formatter options to format message.``True`` or False, default False

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Files for django-db-logs, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size django_db_logs-0.1-py3-none-any.whl (8.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django-db-logs-0.1.tar.gz (5.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page