Skip to main content

CLI for coloring lines from stdin based on a key identified by a regular expression

Project description

Colorby

Colorby is a Python program that makes it easier to understand interleaved log lines by coloring each line based on a matching part.

Example:

# Color some logs from systemd based on service name
$ journalctl _COMM=systemd --since -20m | grep '\.service' | colorby '\S+\.service'
Jun 07 14:36:03 iroh systemd[1]: Starting NetworkManager-dispatcher.service - Network Manager Script Dispatcher Service...
Jun 07 14:36:03 iroh systemd[1]: Started NetworkManager-dispatcher.service - Network Manager Script Dispatcher Service.
Jun 07 14:36:13 iroh systemd[1]: NetworkManager-dispatcher.service: Deactivated successfully.
Jun 07 14:37:59 iroh systemd[1]: Starting packagekit.service - PackageKit Daemon...
Jun 07 14:37:59 iroh systemd[1]: Started packagekit.service - PackageKit Daemon.
Jun 07 14:37:59 iroh systemd[1]: Starting flatpak-system-helper.service - flatpak system helper...
Jun 07 14:37:59 iroh systemd[1]: Started flatpak-system-helper.service - flatpak system helper.
Jun 07 14:43:09 iroh systemd[1]: packagekit.service: Deactivated successfully.
Jun 07 14:43:09 iroh systemd[1]: packagekit.service: Consumed 1.177s CPU time, 120.1M memory peak.
Jun 07 14:47:59 iroh systemd[1]: flatpak-system-helper.service: Deactivated successfully.
Jun 07 14:51:10 iroh systemd[1]: Starting fprintd.service - Fingerprint Authentication Daemon...
Jun 07 14:51:10 iroh systemd[1]: Started fprintd.service - Fingerprint Authentication Daemon.
Jun 07 14:51:40 iroh systemd[1]: fprintd.service: Deactivated successfully.

Note how this makes it easier to identify the lines corresponding to each service despite their interleaving.

(If you’re reading this on GitHub, you won’t see the colors. Read it on lumeh.org instead!)

Usage

For one-off uses, I recommend running the tool via uvx or pipx:

$ uvx colorby --help
usage: colorby [mode options] [other options] [REGEX]

Color each line from stdin based on its key identified by REGEX.
[…]

For more regular use, install the package using your preferred Python package manager.

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

colorby-0.1.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

colorby-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file colorby-0.1.0.tar.gz.

File metadata

  • Download URL: colorby-0.1.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.20

File hashes

Hashes for colorby-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d5b7ac73df0842804082e4c01a2f13166543e765ca2f6faab4db68d16ff00eac
MD5 2f7247adf7df1da63633e65f61dd31bd
BLAKE2b-256 8c8ad4d139dbac253e2f8713b36629e45d57b051c3d43fe42599cf4d52913621

See more details on using hashes here.

File details

Details for the file colorby-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: colorby-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.20

File hashes

Hashes for colorby-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 975c391273a700a4c3aa6f74c9e15e6351ad67b7ba0a09d5ce9a43396e031d17
MD5 9f96c1c0126f1029ca9bbc1f35c36abb
BLAKE2b-256 f7da5325da0b53c1ae63f3e494a7537c90ca80842630bba2f1eb50a1dcd5b5a6

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