diff options
-rwxr-xr-x | contrib/gnunet-logread | 55 | ||||
-rw-r--r-- | src/arm/gnunet-arm.c | 3 |
2 files changed, 37 insertions, 21 deletions
diff --git a/contrib/gnunet-logread b/contrib/gnunet-logread index d5c8b1676..1a3650d79 100755 --- a/contrib/gnunet-logread +++ b/contrib/gnunet-logread | |||
@@ -1,27 +1,36 @@ | |||
1 | #!/usr/bin/env perl | 1 | #!/usr/bin/env perl |
2 | 2 | # helper tool to make gnunet logs more readable | |
3 | # Usage: | 3 | # try 'gnunet-logread -h' for usage |
4 | # gnunet-service |& gnunet-logread | ||
5 | # gnunet-logread service.log | ||
6 | # | ||
7 | # Options: | ||
8 | # -n <component_name> Name of this component to use for IPC logging. | ||
9 | # -i </path/to/ipc.sock> Path to IPC logging socket. | ||
10 | # Passing on log messages to IPC socket: | ||
11 | # -L <LOGLEVEL> Minimum level of messages to pass on. | ||
12 | # Log levels: NONE, ERROR, WARNING, INFO, DEBUG. | ||
13 | # -m <regex> Only pass on messages matching a regular expression. | ||
14 | 4 | ||
15 | use strict; | 5 | use strict; |
16 | use warnings; | 6 | use warnings; |
17 | 7 | ||
18 | use Getopt::Std; | 8 | use Getopt::Std; |
9 | my (%opts, $name, $ipc, $msg_level, $msg_regex); | ||
10 | getopts ('i:x:n:s:L:m:h', \%opts); | ||
11 | |||
12 | die <<X if $opts{h}; | ||
13 | Usage: | ||
14 | <gnunet-service> |& $0 [<options>] | ||
15 | or | ||
16 | $0 [<options>] <service.log> | ||
17 | |||
18 | Options: | ||
19 | Regular screen output options: | ||
20 | -i <regex> Include only messages that match regex. | ||
21 | -x <regex> Exclude all messages that match regex. | ||
22 | |||
23 | Options to enable message passing to IPC socket: | ||
24 | -n <component_name> Name of this component to use for IPC logging. | ||
25 | -s </path/to/ipc.sock> Path to IPC logging socket. | ||
26 | -L <LOGLEVEL> Minimum level of messages to pass on. | ||
27 | Log levels: NONE, ERROR, WARNING, INFO, DEBUG. | ||
28 | -m <regex> Only pass messages matching a regular expression. | ||
29 | X | ||
30 | |||
19 | use Term::ANSIColor qw(:constants :pushpop); | 31 | use Term::ANSIColor qw(:constants :pushpop); |
20 | $Term::ANSIColor::AUTOLOCAL = 1; | 32 | $Term::ANSIColor::AUTOLOCAL = 1; |
21 | 33 | ||
22 | my (%opts, $name, $ipc, $msg_level, $msg_regex); | ||
23 | getopts ('n:i:L:m:', \%opts); | ||
24 | |||
25 | # Message type numbers to names | 34 | # Message type numbers to names |
26 | my %msgtypes; | 35 | my %msgtypes; |
27 | my $prefix = $ENV{GNUNET_PREFIX} || '/usr'; | 36 | my $prefix = $ENV{GNUNET_PREFIX} || '/usr'; |
@@ -34,17 +43,21 @@ if (open HEADER, $filename) | |||
34 | $msgtypes{$2} = $1 if /^\s*#define\s+GNUNET_MESSAGE_TYPE_(\w+)\s+(\d+)/i; | 43 | $msgtypes{$2} = $1 if /^\s*#define\s+GNUNET_MESSAGE_TYPE_(\w+)\s+(\d+)/i; |
35 | } | 44 | } |
36 | close HEADER; | 45 | close HEADER; |
37 | } | 46 | } else { |
38 | else | 47 | warn <<X; |
39 | { | 48 | Could not read $filename for message codes: |
40 | warn "$filename: $!, try setting \$GNUNET_PREFIX"; | 49 | $!. |
50 | Please provide a \$GNUNET_PREFIX environment variable to replace "/usr". | ||
51 | Try also '$0 -h' for help | ||
52 | |||
53 | X | ||
41 | } | 54 | } |
42 | 55 | ||
43 | my %levels = ( NONE => 0, ERROR => 1, WARNING => 2, INFO => 4, DEBUG => 8 ); | 56 | my %levels = ( NONE => 0, ERROR => 1, WARNING => 2, INFO => 4, DEBUG => 8 ); |
44 | if (exists $opts{n}) | 57 | if (exists $opts{n}) |
45 | { | 58 | { |
46 | $name = $opts{n}; | 59 | $name = $opts{n}; |
47 | $ipc = $opts{i} || '/tmp/gnunet-logread-ipc.sock'; | 60 | $ipc = $opts{s} || '/tmp/gnunet-logread-ipc.sock'; |
48 | $msg_level = exists $levels{$opts{L}} ? $levels{$opts{L}} : 0; | 61 | $msg_level = exists $levels{$opts{L}} ? $levels{$opts{L}} : 0; |
49 | $msg_regex = $opts{m}; | 62 | $msg_regex = $opts{m}; |
50 | print STDERR "RE: /$msg_regex/\n" if defined $msg_regex; | 63 | print STDERR "RE: /$msg_regex/\n" if defined $msg_regex; |
@@ -83,6 +96,8 @@ while (<>) | |||
83 | print IPC "$time\t$name\t$level: $msg\n"; | 96 | print IPC "$time\t$name\t$level: $msg\n"; |
84 | } | 97 | } |
85 | } | 98 | } |
99 | next if $opts{x} and /$opts{x}/io; | ||
100 | next if $opts{i} and not /$opts{i}/io; | ||
86 | 101 | ||
87 | # Timestamp (e.g. Nov 01 19:36:11-384136) | 102 | # Timestamp (e.g. Nov 01 19:36:11-384136) |
88 | s/^([A-Z][a-z]{2} .[0-9] [0-9:]{8}(?:-[0-9]{6})?)/YELLOW $1/e; | 103 | s/^([A-Z][a-z]{2} .[0-9] [0-9:]{8}(?:-[0-9]{6})?)/YELLOW $1/e; |
diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c index 4501ed036..75ade59da 100644 --- a/src/arm/gnunet-arm.c +++ b/src/arm/gnunet-arm.c | |||
@@ -544,7 +544,8 @@ list_callback (void *cls, | |||
544 | ret = 3; | 544 | ret = 3; |
545 | return; | 545 | return; |
546 | } | 546 | } |
547 | FPRINTF (stdout, "%s", _("Running services:\n")); | 547 | if (! quiet) |
548 | FPRINTF (stdout, "%s", _("Running services:\n")); | ||
548 | for (i = 0; i < count; i++) | 549 | for (i = 0; i < count; i++) |
549 | FPRINTF (stdout, "%s\n", list[i]); | 550 | FPRINTF (stdout, "%s\n", list[i]); |
550 | al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL); | 551 | al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL); |