+my %pid;
+
+# Get options
+while (($_ = $ARGV[0]) =~ /^-/) {
+ shift;
+ if (/-location/i) {
+ $opt_print_location = 1; shift;
+ } elsif (/-h(elp)?$|-u(sage)?$/i) {
+ print<<EOH
+colorize.pl - Log colorizer for SimGrid
+Syntax:
+
+ colorize.pl [options] <file>
+
+ where <file> 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