9 avr. 2014

Color your logs

Log files are a pain to read. When colored a bit, you start having a better understanding of what it going on under the hood.


This is achieved via a simple tail replacement: colortail.

On OSX, hit the following command:
brew install colortail

On Ubuntu, use your favorite package system command:
sudo apt-get install colortail

Now, in your ~/.bashrc or your ~/.zshrc, add a simple aliases:
alias tail='colortail -k ~/.colortail/conf.default '

Create a ~/.colortail dir where you can put your colored theme files:
mkdir ~/. colortail

Here is my ~/.colortail/conf.default file:
COLOR brightred
{
# matches the word ERROR
^.*(ERROR|error).*$
}
COLOR yellow
{
# matches the word WARNING
^.*(WARNING|warning).*$
}
COLOR green
{
# matches the word INFO
^.*(INFO|info).*$
}
COLOR grey
{
# matches the word DEBUG
^.*(DEBUG|debug).*$
}
COLOR brightblue
{
# matches the time
^.*([0-9]{2}:[0-9]{2}:[0-9]{2}).*$
}

Aucun commentaire:

Enregistrer un commentaire