3 # Copyright (c) 2005, 2007, 2010, 2014. The SimGrid Team.
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the license (GNU LGPL) which comes with this package.
9 $col_white = "\033[00m";
10 $col_black = "\033[30m";
11 $col_red = "\033[31m";
12 $col_green = "\033[32m";
13 $col_yellow = "\033[33m";
14 $col_blue = "\033[34m";
15 $col_purple = "\033[35m";
16 $col_cyan = "\033[36m";
17 $col_ltgray = "\033[37m";
18 $col_darkgray = "\033[30m";
20 $col_norm = $col_white;
21 $col_background = "\033[07m";
22 $col_brighten = "\033[01m";
23 $col_underline = "\033[04m";
24 $col_blink = "\033[05m";
26 # Customize colors here...
28 $col_default = $col_ltgray;
30 $col_green, $col_yellow,
31 $col_purple, $col_cyan,
33 $col_background . $col_green,
34 $col_background . $col_yellow, $col_background . $col_purple,
35 $col_background . $col_cyan, $col_background . $col_red,
36 $col_background . $col_blue, $col_background . $col_magenta,
43 while (($_ = $ARGV[0]) =~ /^-/) {
46 $opt_print_location = 1; shift;
47 } elsif (/-h(elp)?$|-u(sage)?$/i) {
49 colorize.pl - Log colorizer for SimGrid
52 colorize.pl [options] <file>
54 where <file> is a text file of values or '-' for STDIN
56 Options: () denote short version
58 -location Print the location in the code of the message.
68 unless (defined($pid{$pid})) {
69 # first time we see this pid. Affect it a color
70 $pid{$pid}=(scalar keys %pid) % (scalar @coltab);
72 return $coltab[$pid{$pid}];
76 my($host,$procname,$pid,$date,$location,$xbt_channel,$message)=@_;
79 printf "[% 10.6f]",$date;
83 if(defined($location)) {
84 printf "[%10s:%-10s] %s ",$host,$procname,$location;
86 printf "[%10s:%-10s]",$host,$procname;
92 # Read the messages and do the job
94 $orgline = $thisline = $_;
96 # Typical line [Gatien:slave:(9) 11.243148] msg/gos.c:137: [msg_gos/DEBUG] Action terminated
97 if ($thisline =~ /^\[(.+):([^:]+):\((\d+)\) ([\d\.]*)\] ([^\[]*) \[([^\[]*)\] (.*)$/) {
102 if($opt_print_location) {
111 print_line($host,$procname,$pid,$date,$location,$xbt_channel,$message);
112 # Typical line [Boivin:slave:(2) 9.269357] [pmm/INFO] ROW: step(2)<>myrow(0). Receive data from TeX
113 } elsif ($thisline =~ /^\[([^:]+):([^:]+):\((\d+)\) ([\d\.]*)\] \[([^\[]*)\] (.*)$/) {
120 print_line($host,$procname,$pid,$date,undef,$xbt_channel,$message);
121 } elsif ( $thisline =~ /^==(\d+)== (.*)$/) {
122 # take care of valgrind outputs
123 print pidcolor($1)."$2\n";
126 print $col_default. $orgline;