django-db-logger
Django logging in database. For large projects please use Sentry
Screenshot
Dependency
Django>=1.9
Python 2.7+/3.6+
License
WTFPL
Quick start
Install
pip install django-db-logger
Add “django_db_logger” to your INSTALLED_APPS setting like this
INSTALLED_APPS = (
...
'django_db_logger',
)
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_logger.db_log_handler.DatabaseLogHandler'
},
},
'loggers': {
'db': {
'handlers': ['db_log'],
'level': 'DEBUG'
},
'django.request': { # logging 500 errors to database
'handlers': ['db_log'],
'level': 'ERROR',
'propagate': False,
}
}
}
Run python manage.py migrate to create django-db-logger models.
Use django-db-logger like this
import logging
db_logger = logging.getLogger('db')
db_logger.info('info message')
db_logger.warning('warning message')
try:
1/0
except Exception as e:
db_logger.exception(e)
Options
DJANGO_DB_LOGGER_ADMIN_LIST_PER_PAGE: integer. list per page in admin view. default 10
DJANGO_DB_LOGGER_ENABLE_FORMATTER: boolean. Using formatter options to format message. True or False, default False
Build your own database logger :hammer:
Create a new app and add it to INSTALLED_APPS
Copy files django-db-logger/models.py, django-db-logger/admin.py, django-db-logger/db_log_handler.py to the app folder
Replace DJANGO_DB_LOGGER_ADMIN_LIST_PER_PAGE in admin.py with an integer
Replace DJANGO_DB_LOGGER_ENABLE_FORMATTER in db_log_handler.py with True or False. Remove MSG_STYLE_SIMPLE, it was not used.
Replace logger class django_db_logger.db_log_handler.DatabaseLogHandler in your Settings with the new logger class
Customize the looger to meet your needs. :beer:
Metadata
Release files for django-db-logger 0.1.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-db-logger-0.1.13.tar.gz | 10.2 kB | Without provenance | Details for django-db-logger-0.1.13.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_db_logger-0.1.13-py3-none-any.whl | Python 3 | none | any | Details for django_db_logger-0.1.13-py3-none-any.whl |
Total release size: 18.7 kB
Release files / django-db-logger-0.1.13.tar.gz
| Download URL | django-db-logger-0.1.13.tar.gz |
|---|---|
| Size | 10.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a299a08638a741eb0b1d192f2a27eae57ed5118673c2aa916467f2e060c24e72
|
|
BLAKE2b-256 checksum How to use checksums |
b94d7a599b6c0c5ad63386ffff10b865e5729ba40a1fd49c8b152d71c62f7bb1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / django_db_logger-0.1.13-py3-none-any.whl
| Download URL | django_db_logger-0.1.13-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7a1741468c4dc5e7f7cb6f06e1981b16cedff81d3d04d8d926c82b814a247133
|
|
BLAKE2b-256 checksum How to use checksums |
0944da602c708b8c12e6603f2e1429b670e2988823b0a194ad1b4bccb344a77e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Security for django-db-logger 0.1.13
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.