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.1.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: red_logging-0.1.1.tar.gz
  • Upload date:
  • Size: 18.2 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.1.tar.gz
Algorithm Hash digest
SHA256 aa01030ada8001b4fb65a0da3d8b4763625332b9375f73b1fcb509e12d1d57f2
MD5 b3917deb6a5bdfd46da41d346a311c52
BLAKE2b-256 5258c3617c19cfa6102812b4da65faef942afb16412266a641b8954aeb21e5ec

See more details on using hashes here.

File details

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

File metadata

  • Download URL: red_logging-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e9b17a3203b65868a53c0eb899ebfb72b4e4c297680838f0df27b9f97a0d861d
MD5 ede88630c76157c79fab9cceeee06c56
BLAKE2b-256 d825faa27e013a5c4336885c6a585abb3c7aa397c52f42982e6adc5b6466f5fa

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