Skip to main content

Helpful classes, functions, & utilities for the stdlib `logging` module. No external dependencies.

Project description

red-log

Helpful classes, functions, & utilities for the stdlib logging module. No external dependencies.

Project Links

Site URL
🏠 Repository Github: redjax/red-logging
📚 Docs ReadTheDocs
🐍 Pypi projects/red-logging

Why?

I wanted to learn the stdlib logging module, and found I liked configuring my logger(s) with logging.config.dictConfig(). However, I did not want to have to continually check reference pages, copy/paste code, and do all the logging setup by hand each time.

red-log does not import any 3rd party modules, only Python's stdlib modules are used. This package does not necessarily aim to simplify configuring logging, but the config classes help by exposing configuration options for the logging module's formatters, handlers, and loggers.

Logger Configuration

With dictConfig()

Base config dict:

{
    "version": 1,
    "disable_existing_loggers": False,
    "propagate": True,
    "root": {},
    "formatters": {},
    "handlers": {},
    "loggers": {}
}
from logging.config import dictConfig

logging_configdict: dict = {
    "version": 1,
    "disable_existing_loggers": false,
    "propagate": true,
    "root": {
        "": {
            "handlers": [
                "console"
            ],
            "level": "NOTSET"
        }
    },
    "formatters": {
        "default": {
            "format": "[%(asctime)s] [%(levelname)s] > [%(filename)s:%(lineno)d] [%(funcName)s]: %(message)s",
            "datefmt": "%Y-%m-%d %H:%M:%S"
        }
    },
    "handlers": {
        "console": {
            "class": "logging.StreamHandler",
            "formatter": "default",
            "level": "DEBUG",
            "stream": "ext://sys.stdout"
        }
    },
    "loggers": {
        "": {
            "handlers": [
                "console"
            ],
            "level": "NOTSET"
        }
    }
}

dictConfig(logging_configdict)
log = logging.getLogger(__name__)

log.info("Logger configured")

Links

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

red_logging-0.1.2.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

red_logging-0.1.2-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

Details for the file red_logging-0.1.2.tar.gz.

File metadata

  • Download URL: red_logging-0.1.2.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.15.4 CPython/3.11.6 Linux/5.15.0-107-generic

File hashes

Hashes for red_logging-0.1.2.tar.gz
Algorithm Hash digest
SHA256 eba2957ba2d4e917cc81042f4ae08ac9a6222c8272774a2e2e61fb054557557e
MD5 c80aee7fa5849f8fb6de759a9f8d5f22
BLAKE2b-256 cd614cc777d804295fbb519cadc660dcdcd1dfb9b2d7beafbb74d0937b7c18a6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: red_logging-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 25.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.15.4 CPython/3.11.6 Linux/5.15.0-107-generic

File hashes

Hashes for red_logging-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e766a21c649c74ee510524ee0fb03536762ed7a5a5b2389a8fc05dfad7cfe89d
MD5 1630b041ff863136ae8ab90153eee978
BLAKE2b-256 ef8cf8cdc2a1abd84b56b8274a6406ef17836f0175e7b7fe5ad1dd1bcb18c0f8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page