A python script to display log files with colors.
Python
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README
colorex
setup.py

README

    colorex is a powerful console tool that displays files highlighting some patterns with colors
    Copyright (C) 2011  http://www.scopart.fr
    
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see http://www.gnu.org/licenses/gpl-3.0.txt.

Installation
============
if you haven't setuptools installed you can just copy the "colorex" script into your path (eg: /usr/local/bin)
don't forget to check that colorex is executable.

else:
python setup.py install
 
Usage
=====
  colorex [options] [file1] [file2] ...

Display files or sdtin with pretty colors for matched patterns. if you don't specify
files, stdin is used.

Options
=======
--version                         show program's version number and exit
--help, -h                        show this help message and exit
--blue=BLUE, -b BLUE              display BLUE pattern in blue
--red=RED, -r RED                 display RED pattern in red
--green=GREEN, -g GREEN           display GREEN pattern in green
--yellow=YELLOW, -y YELLOW        display YELLOW pattern in yellow
--magenta=MAGENTA, -m MAGENTA     display MAGENTA pattern in magenta
--cyan=CYAN, -c CYAN              display CYAN pattern in cyan
--bblue=BBLUE, -B BBLUE           display BBLUE pattern in blue background
--bred=BRED, -R BRED              display BRED pattern in red background
--bgreen=BGREEN, -G BGREEN        display BGREEN pattern in green background
--byellow=BYELLOW, -Y BYELLOW     display BYELLOW pattern in yellow background
--bmagenta=BMAGENTA, -M BMAGENTA  display BMAGENTA pattern in magenta background
--bcyan=BCYAN, -C BCYAN           display BCYAN pattern in cyan background
--blink=BLINK, -K BLINK           display BLINK pattern blinking (not widely supported)
--bold=BOLD, -D BOLD              display BOLD pattern in bold
--undrln=UNDRLN, -u UNDRLN        display UNDRLN pattern underlined
--bisounours, -N                  display with random colors

Regular expressions are interpreted, so if you want to match a '*' or a '[' or any element of the regexp grammar
you have to escape it with a backslash.

Examples
========
to display every word "ERROR" in red of foo.txt, type:
colorex --red ERROR foo.txt

to watch logfile.txt displaying "WARNING" in yellow and "INFO" in green:
tail -f logfile.txt | colorex -y WARNING --green INFO
exit with CTRL c

to display "(" and ")" contained in foo.txt in blue: 
colorex -b '\(|\)' foo.txt

to diplay in red "FATAL" or "ERROR" and strings like [1234] or [4567] with red background, just type:
colorex -r 'ERROR|FATAL' -R '\[[0-9]{4}\]'

another case:
tail -f /var/log/syslog | colorex -G '[0-9]{2}:[0-9]{2}:[0-9]{2}' -b $(hostname) -M '\[[0-9]{1,5}\]' -y root

ignore case (case insensitive):
prepend search word with (?i) to match without considering case
    tail -f logfile | colorex  --r '(?i)hello'
this will match 'hello', 'Hello' 'HELLO' ..etc