Skip to main content

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


Download files

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

Source Distribution

python-advanced-logger-0.1.2.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

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

python_advanced_logger-0.1.2-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

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

Hashes for python-advanced-logger-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6fce1639ea302d5916bf4e1fcd6d26bd12461ed6b92b9dde2aacd4b047f72842
MD5 8cb54ff93774f8a6783d740979345b22
BLAKE2b-256 c7ecf3575ec3d711eba989faf0bfb550ef4f77da4ea0100a69ab54ed8a723f1f

See more details on using hashes here.

File details

Details for the file python_advanced_logger-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for python_advanced_logger-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 41622d5005f3c4a15703c07e7ee1417bb7cfdb63e202e46964a86ba827e24ddb
MD5 081a76e9815a83b392396dca4cde6654
BLAKE2b-256 759cde30de654a743fbd89831730626cd67572b78b6918cb48cc1c207482fc71

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