X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1e2104d6715a3038c8ff9dc26631c08342c4c868..09f286c26a7cabb1d5d5cfda4ecd26e06cd23080:/tools/MSG_visualization/colorize.pl diff --git a/tools/MSG_visualization/colorize.pl b/tools/MSG_visualization/colorize.pl index 39da01fd6a..366f1cbc00 100755 --- a/tools/MSG_visualization/colorize.pl +++ b/tools/MSG_visualization/colorize.pl @@ -30,10 +30,47 @@ my (@coltab) = ( $col_background . $col_blue, $col_background . $col_magenta, ); +my %pid; + +# Get options +# +while (($_ = $ARGV[0]) =~ /^-/) { + shift; + if (/-location/i) { + $opt_print_location = 1; shift; + } elsif (/-h(elp)?$|-u(sage)?$/i) { + print< + + where is a text file of values or '-' for STDIN + +Options: () denote short version + + -location Print the location in the code of the message. +EOH +; + exit; + } +} + +sub pidcolor { + my $pid = shift; + + unless (defined($pid{$pid})) { + # first time we see this pid. Affect it a color + $pid{$pid}=(scalar keys %pid) % (scalar @coltab); + } + return $coltab[$pid{$pid}]; +} + +# Read the messages and do the job while (<>) { $orgline = $thisline = $_; - if ( $thisline =~ /^\[(\w+):(\w+):\((\d+\)) ([0-9\.]*)\] ([^\[]*) \[([^\[]*)\] (.*)$/ ) { + if ( $thisline =~ /^\[([^:]+):([^:]+):\((\d+)\) ([\d\.]*)\] ([^\[]*) \[([^\[]*)\] (.*)$/ ) { $host=$1; $procname=$2; $pid=$3; @@ -42,15 +79,26 @@ while (<>) { $xbt_channel=$6; $message=$7; + $location =~ s/:$//; + print $col_norm; printf "[% 10.3f]",$date; - print $coltab[($pid-1) % scalar(@coltab)]; - printf "[%10s:%-10s]",$host,$procname; + + print pidcolor($pid); + if($opt_print_location) { + printf "[%10s:%-10s %s ]",$host,$procname,$location; + } else { + printf "[%10s:%-10s]",$host,$procname; + } print " $message"; print $col_norm."\n"; - next; + } elsif ( $thisline =~ /^==(\d+)== (.*)$/) { + # take care of valgrind outputs + print pidcolor($1)."$2\n"; + + } else { + print $col_default. $orgline; } - print $col_default. $orgline; } print $col_norm;