ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philipp Meier <me...@o-matic.de>
Subject Colorize Ant output on unix
Date Mon, 30 Jul 2001 13:14:52 GMT
Hello Ant-Users,

I've hacked together a little perl script which will
colorize ant's output. It's tested on linux and I like
it:

----- snipp -----
#!/usr/bin/perl -w
#
# color-ant 0.9 2001-07-30 meier@o-matic.de
# 
# perl script to give ant nice colors for readabiliy
#
# Philipp Meier <meier@o-matic.de>
#
# Based on:
#
#    $Id: loco,v 1.1.1.1 2000/12/14 19:52:34 jules Exp $
#
#    perl script to give /var/log/messages nice colors for readability
#
#     Jules Stuifbergen <jules@zjuul.net>
#     (I was bored, rewrote 'logcolorise.pl' from Michael Babcock from scratch)
#  
#     Thanks Jeffrey Paul <sneak@datavibe.net> for several improvements
#            Cristian Ionescu-Idbohrn <cii@axis.se> for better patterns

use Term::ANSIColor;
use strict;

$Term::ANSIColor::AUTORESET++;         # reset color after each print
$SIG{INT} = sub { print "\n"; exit; }; # reset color after Ctrl-C
$| = 1;                                # unbuffer STDOUT;

# 'palette'
my $date_color    = "cyan";
my $host_color    = "magenta";
my $service_color = "blue";

my $alert_color   = "red";
my $warn_color    = "yellow";
my $good_color    = "green";

my $alert_word_color   = "bold red";
my $warn_word_color    = "yellow";
my $good_word_color    = "green";

my %rules = (
              '^\S+:'                      => "cyan",
              '^\s*\[.*\]\s+'              => "blue",
              '(\d+\s*)?(error|failure)s?' => "bold red",
              'fail(ed)?'                  => "bold red",
              '(\d+\s*)?(warnings?|warn)'  => "red",
              '[./]\S*/\S*(:\d+)?:?'       => "green",
             );


#### Main loop
#

while (<>) {
        study;
        my $regex;
        foreach $regex (keys %rules) {
                s/$regex/colored($&,$rules{$regex})/gie;
        }
        print;
}
--- snip ---

my $0.02
	-billy.
-- 
Philipp Meier                              o-matic GmbH
Geschäftsführer                  Pfarrer-Weiß-Weg 16-18
Tel.: +49-(0)700-66284236                     89077 Ulm

Mime
View raw message