advanced python logging tools contains elasticsearch and file logger
Project description
PythonAdvanceLogger
Python Advance logger capable to log every event with django default logger, elasticsearch, and file log This package use as a python standard logger as a base logger and add extra features for better log handling by lesser actions in python and django
This package aims to create log like asp.net logger which capable to distribute log over elasticsearch, file, and other extra loggers
This package contains 4 main modules:
- Python default logger
- Elasticsearch logger (Using http requests)
- file logger
Install package by:
How to setup package in django:
After installation advanceLogging package from pypi, you can setup you logger as a shown below:
elsConf = ElasticSearchConf(hosts=["your host: port"],
user="username",
password="pass",
indicator="your elastic index",
maxConnection=10)
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"advance_logger": {
"format": "%(asctime)s %(created)f %(filename)s %(funcName)s %(levelname)s %(levelno)s %(lineno)d %(module)s"
" %(name)s %(levelname)s %(message)s %(pathname)s",
"datefmt": "%Y-%m-%dT%H:%M:%S%z",
"class": "advanceLogger.AdvanceLogFormatter"
}
},
"handlers": {
"console": {
"class": "advanceLogger.AdvanceLogHandler",
"formatter": "advance_logger",
"els_conf": elsConf
}
},
"loggers": {
# Make sure to replace the following logger's name for yours
"django": {
"handlers": ["console"],
"level": "INFO",
},
}
}
After define logger in your django settings.py you can use this logger every place of your codes like below:
import logging
logger = logging.getLogger("django_structlog_demo_project")
class Startup:
def __init__(self):
logger.info("start app", extra={"extraParams": 1})
logger.debug("start app")
logger.error('test')
requests.get('https://reqres.in/api/users?page=2')
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 python-advanced-logger-0.1.2.tar.gz.
File metadata
- Download URL: python-advanced-logger-0.1.2.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fce1639ea302d5916bf4e1fcd6d26bd12461ed6b92b9dde2aacd4b047f72842
|
|
| MD5 |
8cb54ff93774f8a6783d740979345b22
|
|
| BLAKE2b-256 |
c7ecf3575ec3d711eba989faf0bfb550ef4f77da4ea0100a69ab54ed8a723f1f
|
File details
Details for the file python_advanced_logger-0.1.2-py3-none-any.whl.
File metadata
- Download URL: python_advanced_logger-0.1.2-py3-none-any.whl
- Upload date:
- Size: 18.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41622d5005f3c4a15703c07e7ee1417bb7cfdb63e202e46964a86ba827e24ddb
|
|
| MD5 |
081a76e9815a83b392396dca4cde6654
|
|
| BLAKE2b-256 |
759cde30de654a743fbd89831730626cd67572b78b6918cb48cc1c207482fc71
|