Developers often have to look at log files. This is sometimes boring, sometimes tedious, but it's a fact of life. It would really help if some special lines, such as errors, warnings etc. could stand out. One way to do it is to use the clog utility.

To make clog usage more streamlined from a terminal, you can define this bash function:

# pipe a log file through clog to get colours
function logless
{
if [ -z "$1" ]; then echo "No file given, exiting" 1>&2 else cat$1 | clog | less -R
fi
}

Don't forget, you need to configure clog so that it is able to recognize the format of your log files, since there is no way it can know it in advance. If you happen to be using glog (Google log) library in its default configuration, try adding these settings to your .clogrc file:

default rule /^W/   --> yellow line
default rule /^E/   --> red line

Read clog manual for further information. Happy logging!

Tags: None
Categories: None |