Skip to main content

color_bucket_logger

https://img.shields.io/pypi/v/color_bucket_logger.svg https://img.shields.io/travis/alikins/color_bucket_logger.svg Documentation Status Updates

Python logging Formatter for colorizing logs per thread, process, logger name, or any record attribute

Using this logging formatter to make log records that share a common attribute share a color automatically.

For example, a process with three threads could show the log entries for each thread in a different color. The same can be done per process, or per logger name. Any log record attribute can be used to choose the color used for the log entry.

The entire log record, the particular log field (‘level’ or ‘process’ for ex.), or a group of fields can be colorized based on an attribute value.

For example, the fields for ‘thread’, ‘threadName’, ‘process’, ‘processName’ could be colorized based on the thread id.

Usage

Examples

Basic config colorized by logger name:

import logging

import color_bucket_logger

log = logging.getLogger('example')
log.setLevel(logging.DEBUG)

log_format = '%(asctime)s %(process)s %(levelname)s %(name)s %(funcName)s -- %(message)s'

# Use logger name for the primary color of each entry
formatter = color_bucket_logger.ColorFormatter(fmt=log_format, default_color_by_attr='name')

handler = logging.StreamHandler()
handler.setLevel(logging.DEBUG)
handler.setFormatter(formatter)

# basicConfig will add our handler to the root logger
# Note 'handlers' arg is py3 only
logging.basicConfig(level=logging.DEBUG, handlers=[handler])

Color Group Examples

Example uses of color_groups:

# color almost everything by logger name
color_groups = [('name', ['filename', 'module', 'lineno', 'funcName', 'pathname'])]

color_groups = [
    ('process', ['default', 'message']),
    ('process', ['processName', 'process']),
    ('thread', ['default', 'threadName', 'message', 'unset', 'processName', 'exc_text']),
    ('thread', ['threadName', 'thread']),
    ]

# color logger name, filename and lineno same as the funcName
color_groups = [('funcName', ['default', 'message', 'unset', 'name', 'filename', 'lineno'])]

# color message same as debug level
color_groups = [('levelname', ['levelname', 'levelno'])]

# color funcName, filename, lineno same as logger name
color_groups = [('name', ['funcName', 'filename', 'lineno'])]

# color groups can be based on non standard 'extra' attributes or log record
# attibutes created from filters. In this example, a 'task' attributes.
color_groups = [('task', ['task_uuid', 'task'])]

# color default, msg and playbook/play/task by the play
color_groups = [('play', ['default','message', 'unset', 'play', 'task'])]

License

  • Free software: MIT license

Features

  • TODO

History

0.2.0 (2019-05-30)

  • Prep for release

0.1.0 (2017-06-15)

  • First release on PyPI.

Metadata

Release files for color-bucket-logger 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for color-bucket-logger 0.2.0
File Size Uploaded Provenance Actions
color_bucket_logger-0.2.0.tar.gz 27.8 kB Without provenance Details for color_bucket_logger-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for color-bucket-logger 0.2.0
File Interpreter ABI Platform Actions
color_bucket_logger-0.2.0-py2.py3-none-any.whl Python 2, Python 3 none any Details for color_bucket_logger-0.2.0-py2.py3-none-any.whl

Total release size: 43.8 kB

Release files / color_bucket_logger-0.2.0.tar.gz

Download URL color_bucket_logger-0.2.0.tar.gz
Size 27.8 kB
Tags Source
SHA-256 checksum
How to use checksums
93192233f18f9181ce4b9de6b69823792a7401d9d7a3cef47a48e26074c4bfc9
BLAKE2b-256 checksum
How to use checksums
f603cec53f0b2ce1a360fc0fd4fd5c8373db46c64bb72bea75f8db249c8bb8da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

Release files / color_bucket_logger-0.2.0-py2.py3-none-any.whl

Download URL color_bucket_logger-0.2.0-py2.py3-none-any.whl
Size 16.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
bd0006b8ac35b3e11472eaa5b68ab6ef5b09525d083bb048a9c47ba1f20ec1f4
BLAKE2b-256 checksum
How to use checksums
ef8926841bbe26c8c3286003b9d8f0f7ec7f2f1dd9f28cc99e51d1b838a0c5c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

Security for color-bucket-logger 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page