grc

Install

general coloriser can be installed via homebrew:
brew install grc

Configuration

We need a general configuration file ~/.grc/grc.conf where we write a regex and a filename per kind of command we call with grc. For example to colorise:
tail -f messages.log
We will call
grc tail -f messages.log
grc will look for entries in ~/.grc/grc.conf that match tail -f messages.log and use the file of the same entry to color the output

Content of ~/.grc/grc.conf

# Colorise messages.log
\b\w+\b.*messages\.log\b
messages.log.conf

Content of ~/.grc/messages.log.conf

# Informative logs
regexp=^\[.*\]\s[\dA-z]+\s(.*)\s+[A]\s(.*)$
colours=cyan
count=line
=====
# More informative logs
regexp=^\[.*\]\s[\dA-z]+\s(.*)\s+[I]\s(.*)$
colours=unchanged
count=line
=====
# Error
regexp=^\[.*\]\s[\dA-z]+\s(.*)\s+[ER]\s(.*)$
colours=red
count=line
=====
# Stacktraces (start with tab)
regexp=^\[.*\]\s[\dA-z]+\s(.*)\s+[R]\s(\t.*)$
colours=none, none, red
count=line

Result

0 comments :

This work is licensed under BSD Zero Clause License | nacho4d ®