Skip to content

Latest commit

 

History

History
80 lines (58 loc) · 2.2 KB

README.md

File metadata and controls

80 lines (58 loc) · 2.2 KB

Harness

Simple script to highlight the logs that you want to see, and can mute those that you don't. It wraps any command line program to parse the log output of the application. It looks for keywords within the output, and colors a slice of the output according to the color associated with a given keyword.

Demo

Operating System Support

This application should work on the big three (i.e., Linux, MacOS, Windows).

Note

This is a simple script and by no means robust. It uses basic ANSI escape sequences to modify output. Ensure your terminal supports ANSI escape sequences.

Build Requirements

python >= v3.10.x

Usage

usage: harness.py [-h] [-f FILE] [-m MODE] [-s STYLE] [-i] command

Capture and colorize log output

positional arguments:
  command               Command to spawn harnessed application

options:
  -h, --help            show this help message and exit
  -f FILE, --file FILE  Configuration file (defaults to 'harness.conf')
  -m MODE, --mode MODE  Colorization method: 'line' or 'word' (defaults to 'line')
  -s STYLE, --style STYLE
                        Color style: '4bit', '8bit', or '24bit' (defaults to '8bit')
  -i, --ignore          Ignore case of matched word (no value expected)

It is recommended to add call-function to terminal config (i.e., .bashrc, powershell profile)

Example for .bashrc:

harness() { python3 <PROJECT PATH>/harness.py "$@" ;}

Example for Powershell $PROFILE:

function harness() { python <PROJECT PATH>\harness.py @args }

Note

Using word mode allows coloring of different words on the same line

Note

Using the -i flag will lowercase the matched words

Config file

The config file can be named anything, if the file flag is passed to specify the path/name. If no file is specified, the script look for harness.conf in the directory in which this script is located.

The expected format for the configuration file is:
[KEY]=[COLOR]

Comments are supported, so long as the first character is # and the base keyword can be used to specify a color that all non-matched output should default to.

Note

A sample config file is provided with this repository harness.conf