Skip to main content

Add colors to plain text lines matching either a Python string or regular expression

Project description

There is at least one existing tool to perform automatic syntax highlighting of code and output ANSI escape sequences. Unfortunately, to the best of the author’s knowledge, there is no existing tool for highlighting lines of log files that contain a particular pattern. Vim’s match and 2match are close, but a little kludgy to use.

The purpose of this tool is to colorize lines matching a particular pattern, to make it easier to highlight relevant lines in a log file, when poring over such files with your coworker or manager.


Assume we have a file with the following contents:

This is an interesting line with some awesome content.
unrelated line
unrelated line
unrelated line
Different topic of interest
unrelated line

Then we can run the following commands to see some of effects we want: -h -l -f 'This is an interesting line=Blue' Input.log -f 'This is an interesting line=Blue' -f 'Different topic=Red' Input.log

# Note that we must run less in raw node to see the colors. -f 'This is an interesting line=Blue' | less -R

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for, version 0.9.1
Filename, size File type Python version Upload date Hashes
Filename, size (3.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page