Created
February 4, 2015 09:47
-
-
Save cybic/9c37faa7ee768d51be4d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
#use Term::ANSIColor qw( :constants ); | |
use Term::ANSIColor; | |
my %COL = ( | |
'DEBUG' => color('magenta'), | |
'INFO' => color('blue'), | |
'WARNING' => color('yellow'), | |
'WARN' => color('yellow'), | |
'ERROR' => color('red'), | |
'DATE' => color('cyan'), | |
'UNKNOWN' => color('bold black') | |
); | |
my $RESET = color('reset'); | |
while ( my $line = <> ) { | |
# Color log severity tags | |
if ( $line =~ m/^(.*?)\[(.*?)\s?\](.*)$/ ) { | |
my $COLCODE = $COL{$2} || $COL{'UNKNOWN'}; | |
$line = "$1\[$COLCODE$2$RESET\]$3\n"; | |
} | |
# Color timestamps | |
$line =~ s/(\d{4}-\d{2}-\d{2}\ \d{2}:\d{2}:\d{2},\d{3})/$COL{'DATE'}$1$RESET/g; | |
print $line; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment