A Django logger that logs to MongoDB using MongoEngine.
Project description
Django MongoEngine Logger
A Django logger that logs to MongoDB using MongoEngine.
Installation
pip install django-mongo-logger
pip install mongoengine
Usage
To configure the logger, add the following to your settings.py file:
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 %(message)s",
},
},
"handlers": {
"console": {
"level": "DEBUG",
"class": "logging.StreamHandler",
"formatter": "verbose",
},
"mongo": {
"level": "DEBUG",
"class": "django_mongoengine_logger.logging.MongoDBHandler",
"log_document_path": "django_mongoengine_logger.documents.LogDocument", # path to you mongo engine log Document if not provided if not provided package will use default Document
},
},
"loggers": {
"django": {
"handlers": ["console"],
"level": "INFO",
"propagate": True,
},
"mongo_log": {
"handlers": ["mongo"],
"level": "DEBUG",
"propagate": False,
},
},
}
log save in mongodb database with default name of django_logs
Example
import logging
logger = logging.getLogger('mongo_log')
logger.debug('This is a debug message')
logger.info('This is an info message')
logger.error('This is an error message')
# you can pass json string to log message too
import json
logger = logging.getLogger(json.dumps({"message": 'mongo_log'}))
logger.debug(json.dumps({"message":'This is a debug message'}))
logger.info(json.dumps({"message":'This is an info message'}))
logger.error(json.dumps({"message":'This is an error message'}))
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please open an issue or submit a pull request for any changes.
Acknowledgements
any contributors to this project will be appreciated.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_mongoengine_logger-0.1.0.tar.gz.
File metadata
- Download URL: django_mongoengine_logger-0.1.0.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.9 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfa6fb5b5b8bce9b3d6ee0469b44e8c1e6e2eeca364f7ee30c298647727eec93
|
|
| MD5 |
cbf52335f201135e991bb71b706ab828
|
|
| BLAKE2b-256 |
a5e762622d72052c59d6426ae564df115cfd84a50f36b8fe8a64e7471c98d28d
|
File details
Details for the file django_mongoengine_logger-0.1.0-py3-none-any.whl.
File metadata
- Download URL: django_mongoengine_logger-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.9 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a248712cd568c0d97dac550ae8911f78b979bc356f193c4343af4f6c38d7b6f
|
|
| MD5 |
46e6f7526557aaf3ff43126f7204b9be
|
|
| BLAKE2b-256 |
634f8fedf1a27a0b29f6b8c8cfa00c1d084337074c8318d1ceb1d3497226ba54
|