Skip to main content

ansilogs

Colored, single-line log output for command-line tools. A small, dependency-free replacement for coloredlogs.install().

import logging

import ansilogs

ansilogs.install(logging.DEBUG)
logging.getLogger(__name__).warning("careful")
2026-10-19 09:35:12 my-host my_tool.cli[4242] WARNING careful
  • One line per record: <time> <host> <name>[<pid>] <LEVEL> <message>; tracebacks follow uncolored.
  • The default style dims the time, host and pid, shows the logger name in cyan and the level name in its severity color (debug output dimmed). style="coloredlogs" reproduces coloredlogs' look byte for byte.
  • highlight_code=True also paints the `backticked` spans of a message (a command to run, an identifier), so they stand out from the sentence around them. The text itself is unchanged. It is off by default, since it recolors part of any message that contains a pair of backticks.
  • Colors only when stderr is a terminal. NO_COLOR (non-empty) disables them, FORCE_COLOR (non-empty) forces them. On Windows the console is switched to ANSI processing; if that fails, output is plain.
  • Records go to whatever sys.stderr is at the time (test capture and live progress displays that redirect stderr keep working).

API

  • install(level=logging.INFO, colors=None, style="default", highlight_code=False): attach the handler to the root logger (once) and show records from level up. colors=None means supports_color(); style is "default" or "coloredlogs" (see STYLES); highlight_code paints the backticked spans of each message.
  • set_level(level): change the shown level (installs the handler if needed).
  • supports_color(stream=None): the color decision used by install().
  • ColoredFormatter(colors=True, hostname=None, style="default", highlight_code=False) and StderrHandler for custom setups.

Migrating from coloredlogs

-import coloredlogs
-coloredlogs.install(level=logging.DEBUG)
+import ansilogs
+ansilogs.install(logging.DEBUG)

Pass style="coloredlogs" to keep the exact coloredlogs colors. coloredlogs.set_level(level) becomes ansilogs.set_level(level). COLOREDLOGS_* environment variables and custom field/level styles are not supported.

Metadata

Release files for ansilogs 1.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 ansilogs 1.2.0
File Size Uploaded Provenance Actions
ansilogs-1.2.0.tar.gz 12.5 kB With provenance Details for ansilogs-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ansilogs 1.2.0
File Interpreter ABI Platform Actions
ansilogs-1.2.0-py3-none-any.whl Python 3 none any Details for ansilogs-1.2.0-py3-none-any.whl

Total release size: 20.3 kB

Release files / ansilogs-1.2.0.tar.gz

Download URL ansilogs-1.2.0.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
55da304534b6853a002585d747add65ae6fefa6cd14da30e1349d649de5a883c
BLAKE2b-256 checksum
How to use checksums
5722bd196aa83bca307de047b0cc96fb66ebf946bbaec3052dddedea28449cd6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / ansilogs-1.2.0-py3-none-any.whl

Download URL ansilogs-1.2.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c1c250c8c5f3d0622208f08fa260682659400276c198362955d3e765a63e7460
BLAKE2b-256 checksum
How to use checksums
4ef9abc0c5ea4e28a7beec37fef68146c78d0a3738dedd92a8fdf5fc1c0f7fd1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Security for ansilogs 1.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ansilogs-1.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

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.

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