Skip to main content

Simple log formatters for colored output.

Project description

LogColor

Stable Version Documentation Status Downloads Test Lint

When making command line interfaces, it's often useful to colorize the output to emphasize salient pieces of information or otherwise enhance the user experience. Unfortunately it's quite cumbersome to add colorized outputs to Python log messages.

ColorFormatter

The ColorFormatter is a logging formatter that parses your log messages and adds color codes to the log messages.

example

ColorStripper

The ColorStripper formatter is the inverse of the ColorFormatter. It strips the color information from your messages so that you can log to a file without it being full of color codes.

Installation

I'm on pypi!

$ pip install log_color

Features

  • Simple to use
  • No external dependencies
  • Compatibility with Python 3.7+, PyPy
  • Fast! Compiled binaries are available for some systems!

http://no-color.org/

LogColor honors the NO_COLOR environment variable.

Developer Setup

This project uses uv for dependency management, command running, etc... install it:

$ curl -LsSf https://astral.sh/uv/install.sh | sh

Makefile

If you're on Linux or OSX, there is a Makefile with a number of helpful targets:

  • make check-types Run mypy static code analysis tools
  • make format-code Runs the ruff code formatter
  • make check-code Validates no code formatting errors or import sorting errors (check only, makes no changes)
  • make wheel Build Python .whl file for distribution
  • make test Run the unittests
  • make docs Build the documentation
  • make freeze List all packages (and their version number) installed in the virtual environment
  • make shell Launch an interactive Python shell in the virtual environment context
  • make clean Remove any files that aren't part of the repo (build artifacts, test reports, etc...)
  • make git-clean Runs the git fsck tool, prunes the reflog, etc...

TIP: If you want to force a target to be re-evaluated (i.e. make env) run make with the -B flag to force it to evaluate.

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

log_color-2.1.0.tar.gz (163.1 kB view details)

Uploaded Source

Built Distribution

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

log_color-2.1.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file log_color-2.1.0.tar.gz.

File metadata

  • Download URL: log_color-2.1.0.tar.gz
  • Upload date:
  • Size: 163.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.17

File hashes

Hashes for log_color-2.1.0.tar.gz
Algorithm Hash digest
SHA256 b6856fbcb6b1f8c91ae1049eaa7e28775569b4fcd228348d552845389dd36e8e
MD5 0ebeba7caa1b800927c1d7634a657388
BLAKE2b-256 dc0f839813e28281d221ccf41d3eb550442eebb5fefd2e7498e271853b692229

See more details on using hashes here.

File details

Details for the file log_color-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: log_color-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.17

File hashes

Hashes for log_color-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f63bc1d38bbfe063b269d92a95cb53fb15cb7f43d1b85668bc6a6d1940b7015a
MD5 ccca757d895a156f49c27fcfe21c948f
BLAKE2b-256 329538a8efda2c9fcb42a0fc8af91bc931ab256a375f0502cb2c7b84a2470a45

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