4 # gnunet-service |& gnunet-logread
5 # gnunet-logread service.log
10 use Term::ANSIColor qw(:constants :pushpop);
11 $Term::ANSIColor::AUTOLOCAL = 1;
13 # Message type numbers to names
15 my $prefix = $ENV{GNUNET_PREFIX} || '/usr';
16 my $filename = "$prefix/include/gnunet/gnunet_protocols.h";
18 if (open HEADER, $filename)
22 $msgtypes{$2} = $1 if /^\s*#define\s+GNUNET_MESSAGE_TYPE_(\w+)\s+(\d+)/i;
28 warn "$filename: $!, try setting \$GNUNET_PREFIX";
33 # Timestamp (e.g. Nov 01 19:36:11-384136)
34 s/^([A-Z][a-z]{2} .[0-9] [0-9:]{8}(?:-[0-9]{6})?)/YELLOW $1/e;
37 s/\b(ERROR )\b/RED $1/ex;
38 s/\b(WARNING)\b/YELLOW $1/ex;
39 s/\b(INFO )\b/GREEN $1/ex;
40 s/\b(DEBUG )\b/BRIGHT_BLACK $1/ex;
43 # TODO: might read the list from $GNUNET_PREFIX/libexec/gnunet/
44 s/\b(multicast|psyc|psycstore|social)\b/BLUE $1/ex;
46 # Add message type names
47 s/(message(?:\s+of)?\s+type\s+)(\d+)/$1 . BRIGHT_CYAN "$msgtypes{$2}" . CYAN " ($2)"/e;