Formatting/coloring log files on the fly with tail and sed

I often monitor MySQL queries for some complex application components that use an ORM (Doctrine).
I’ve just made a special logger that re-runs all the quries with an EXPLAIN and log the “Extra” column of the explain query, in order to spot queries that can be improved. From the log, I pipe the result to “sed” with a regular expression, and colouring some text.
Sure you are not interested in this post. I just write some posts in order to find them easily in the future when I need them, and possibly helpting somebody else googling the same need.
Here the lines I’ve added to my ~/.bashrc
COLOR_RED=`echo -en 'e[31m'`
COLOR_YELLOW=`echo -en 'e[93m'`
COLOR_RESET=`echo -en 'e[00m'`
alias querylog="tail -f /var/www/bnt/Public/application/logs/queries.log | sed -E 

One thought on “Formatting/coloring log files on the fly with tail and sed

  1. I am interested in explanation about EXTRA field logger 🙂 Could you write blog post about it ? I will be interesting for all

Comments are closed.