[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r30494 - gnunet/contrib
From: |
gnunet |
Subject: |
[GNUnet-SVN] r30494 - gnunet/contrib |
Date: |
Fri, 1 Nov 2013 21:54:41 +0100 |
Author: tg
Date: 2013-11-01 21:54:40 +0100 (Fri, 01 Nov 2013)
New Revision: 30494
Added:
gnunet/contrib/logread.pl
Log:
logread
Added: gnunet/contrib/logread.pl
===================================================================
--- gnunet/contrib/logread.pl (rev 0)
+++ gnunet/contrib/logread.pl 2013-11-01 20:54:40 UTC (rev 30494)
@@ -0,0 +1,50 @@
+#!/usr/bin/env perl
+
+# Usage:
+# gnunet-service |& gnunet-logread
+# gnunet-logread service.log
+
+use strict;
+use warnings;
+
+use Term::ANSIColor qw(:constants :pushpop);
+$Term::ANSIColor::AUTOLOCAL = 1;
+
+# Message type numbers to names
+my %msgtypes;
+my $prefix = $ENV{GNUNET_PREFIX} || '/usr';
+my $filename = "$prefix/include/gnunet/gnunet_protocols.h";
+
+if (open HEADER, $filename)
+{
+ while (<HEADER>)
+ {
+ $msgtypes{$2} = $1 if
/^\s*#define\s+GNUNET_MESSAGE_TYPE_(\w+)\s+(\d+)/i;
+ }
+ close HEADER;
+}
+else
+{
+ warn "$filename: $!, try setting \$GNUNET_PREFIX";
+}
+
+while (<>)
+{
+ # Timestamp (e.g. Nov 01 19:36:11-384136)
+ s/^([A-Z][a-z]{2} .[0-9] [0-9:]{8}(?:-[0-9]{6})?)/YELLOW $1/e;
+
+ # Log levels
+ s/\b(ERROR )\b/RED $1/ex;
+ s/\b(WARNING)\b/YELLOW $1/ex;
+ s/\b(INFO )\b/GREEN $1/ex;
+ s/\b(DEBUG )\b/BRIGHT_BLACK $1/ex;
+
+ # Service names
+ # TODO: might read the list from $GNUNET_PREFIX/libexec/gnunet/
+ s/\b(multicast|psyc|psycstore|social)\b/BLUE $1/ex;
+
+ # Add message type names
+ s/(message(?:\s+of)?\s+type\s+)(\d+)/$1 . BRIGHT_CYAN "$msgtypes{$2}" .
CYAN " ($2)"/e;
+
+ print;
+}
Property changes on: gnunet/contrib/logread.pl
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r30494 - gnunet/contrib,
gnunet <=