/[Sack]/trunk/lib/Sack/Color.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/Sack/Color.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 155 - (show annotations)
Fri Oct 9 19:12:05 2009 UTC (14 years, 7 months ago) by dpavlin
File size: 528 byte(s)
color warn lines without lf in red

1 package Sock::Color;
2
3 use warnings;
4 use strict;
5
6 sub BEGIN {
7
8 sub port2color {
9 my $port = shift;
10 return "\e[1m0\e[0m" if $port == 0;
11
12 my $c = ( $port % 6 ) + 31;
13 return "\e[${c}m$port\e[0m";
14 }
15
16 $SIG{__WARN__} = sub {
17 return unless @_;
18 my $msg = join('', @_);
19 if ( $msg =~ s{ line (\d+)\.}{ +$1} ) {
20 $msg =~ s{^(.+)( at .+)}{\e[31m$1\e[0m$2} if $msg !~ m{^#};
21 }
22 $msg =~ s{\[(0|\d\d\d\d)\]}{ '[' . port2color($1) . ']' }eg;
23 print STDERR $msg unless $msg =~ m{^#} && ! $ENV{DEBUG};
24 return 1;
25 };
26
27 }
28
29 1;

  ViewVC Help
Powered by ViewVC 1.1.26