X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/058ad71842ebb98aeb28b42adb14b49031f997d6..29e588dfbb4a57ab7377fadc951aa31f7d836a9b:/tools/MSG_visualization/colorize.pl diff --git a/tools/MSG_visualization/colorize.pl b/tools/MSG_visualization/colorize.pl index 371f3f908b..c346409b4c 100755 --- a/tools/MSG_visualization/colorize.pl +++ b/tools/MSG_visualization/colorize.pl @@ -30,20 +30,95 @@ 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}]; +} + +sub print_line { + my($host,$procname,$pid,$date,$location,$xbt_channel,$message)=@_; + + print $col_norm; + printf "[% 10.6f]",$date; + + print pidcolor($pid); + + if(defined($location)) { + printf "[%10s:%-10s] %s ",$host,$procname,$location; + } else { + printf "[%10s:%-10s]",$host,$procname; + } + print " $message"; + print $col_norm."\n"; +} + +# Read the messages and do the job while (<>) { $orgline = $thisline = $_; - if ( $thisline =~ /^\[[0-9\.]*\] P[0-9]* \|/ ) { - ( $number, $message ) = split ( / \| /, $thisline ); - chomp $message; - $head = $number; - $number =~ s/^\[[0-9\.]*\] P//; - $number =~ s/^ .*$//; - $head =~ s/^(\[.*\]) (.*)$/$col_norm$1 $coltab[($number-1) % scalar(@coltab)]$2/; - print $head. " " . $message . $col_norm . "\n"; - next; + # Typical line [Gatien:slave:(9) 11.243148] msg/gos.c:137: [msg_gos/DEBUG] Action terminated + if ($thisline =~ /^\[(.+):([^:]+):\((\d+)\) ([\d\.]*)\] ([^\[]*) \[([^\[]*)\] (.*)$/) { + $host=$1; + $procname=$2; + $pid=$3; + $date=$4; + if($opt_print_location) { + $location=$5; + $location =~ s/:$//; + } else { + $location = undef; + } + $xbt_channel=$6; + $message=$7; + + print_line($host,$procname,$pid,$date,$location,$xbt_channel,$message); + # Typical line [Boivin:slave:(2) 9.269357] [pmm/INFO] ROW: step(2)<>myrow(0). Receive data from TeX + } elsif ($thisline =~ /^\[([^:]+):([^:]+):\((\d+)\) ([\d\.]*)\] \[([^\[]*)\] (.*)$/) { + $host=$1; + $procname=$2; + $pid=$3; + $date=$4; + $xbt_channel=$5; + $message=$6; + print_line($host,$procname,$pid,$date,undef,$xbt_channel,$message); + } 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;