diff options
author | Carlo von lynX <lynX@time.to.get.psyced.org> | 2016-07-28 13:05:33 +0000 |
---|---|---|
committer | Carlo von lynX <lynX@time.to.get.psyced.org> | 2016-07-28 13:05:33 +0000 |
commit | bc5798bad9474460df4943701933c9444f6a2305 (patch) | |
tree | fb14d75ba3c21cc9a45a1500d138b99266af10fc /contrib | |
parent | 9517e45e19a2552554b2a4e2c6faf48d04c78ffb (diff) | |
download | gnunet-bc5798bad9474460df4943701933c9444f6a2305.tar.gz gnunet-bc5798bad9474460df4943701933c9444f6a2305.zip |
gnunet-logread with intelligent usage message and proper perldoc
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/gnunet-logread | 89 |
1 files changed, 68 insertions, 21 deletions
diff --git a/contrib/gnunet-logread b/contrib/gnunet-logread index 2e54d133f..f58758cb9 100755 --- a/contrib/gnunet-logread +++ b/contrib/gnunet-logread | |||
@@ -6,30 +6,19 @@ use strict; | |||
6 | use warnings; | 6 | use warnings; |
7 | my $DEFAULT_SOCKET = '/tmp/gnunet-logread-ipc.sock'; | 7 | my $DEFAULT_SOCKET = '/tmp/gnunet-logread-ipc.sock'; |
8 | 8 | ||
9 | use Getopt::Std; | 9 | print STDERR <<X if -t STDIN and $#ARGV == -1; |
10 | my (%opts, $name, $ipc, $msg_level, $msg_regex); | 10 | *** For a usage message, try '$0 -h'. |
11 | getopts ('i:x:n:s:L:m:fh', \%opts); | 11 | *** For documentation, try 'perldoc $0'. |
12 | 12 | *** Listening for GNUNET_log events on STDIN. Type CTRL-D to terminate. | |
13 | die <<X if $opts{h}; | ||
14 | Usage: | ||
15 | <gnunet-service> |& $0 [<options>] | ||
16 | or | ||
17 | $0 [<options>] [<logfile>] | ||
18 | 13 | ||
19 | Options: | 14 | X |
20 | -f Follow input from IPC FIFO socket. | ||
21 | 15 | ||
22 | Regular screen output options: | 16 | use Getopt::Std; |
23 | -i <regex> Include only messages that match <regex>. | 17 | my (%opts, $name, $ipc, $msg_level, $msg_regex); |
24 | -x <regex> Exclude all messages that match <regex>. | 18 | getopts ('i:x:n:s:L:m:fhq', \%opts); |
25 | 19 | ||
26 | Options to enable message passing to IPC socket: | 20 | use Pod::Usage qw( pod2usage ); |
27 | -n <component_name> Name of this component to use for IPC logging. | 21 | die pod2usage if $opts{h}; |
28 | -s </path/to/ipc.sock> Default = $DEFAULT_SOCKET | ||
29 | -L <LOGLEVEL> Minimum level of messages to pass on. | ||
30 | Log levels: NONE, ERROR, WARNING, INFO, DEBUG. | ||
31 | -m <regex> Only pass messages matching a regular expression. | ||
32 | X | ||
33 | 22 | ||
34 | use POSIX qw(mkfifo); | 23 | use POSIX qw(mkfifo); |
35 | 24 | ||
@@ -150,3 +139,61 @@ sub perform { | |||
150 | print; | 139 | print; |
151 | } | 140 | } |
152 | 141 | ||
142 | __END__ | ||
143 | |||
144 | =pod | ||
145 | |||
146 | =head1 NAME | ||
147 | |||
148 | gnunet-logread - a GNUnet log analyzer, colorizer and aggregator | ||
149 | |||
150 | =head1 SYNOPSIS | ||
151 | |||
152 | <gnunet-service> |& $0 [<options>] | ||
153 | or | ||
154 | $0 [<options>] [<logfile>] | ||
155 | |||
156 | Options: | ||
157 | -f Follow input from IPC FIFO socket. | ||
158 | |||
159 | Regular screen output options: | ||
160 | -i <regex> Include only messages that match <regex>. | ||
161 | -x <regex> Exclude all messages that match <regex>. | ||
162 | -q Quiet: Do not show usage advice to new users. | ||
163 | |||
164 | Options to forward messages to the IPC FIFO socket: | ||
165 | -n <component_name> Name of the component we are forwarding messages for. | ||
166 | -s </path/to/ipc.sock> Default = $DEFAULT_SOCKET | ||
167 | -L <LOGLEVEL> Minimum level of messages to forward: | ||
168 | Log levels: NONE, ERROR, WARNING, INFO, DEBUG. | ||
169 | -m <regex> Only forward messages matching a regular expression. | ||
170 | |||
171 | See 'perldoc gnunet-logread' for a longer explanation. | ||
172 | |||
173 | =head1 MOTIVATION | ||
174 | |||
175 | GNUnet debug logs are a tedious read, but given a complex system that we | ||
176 | cannot run all parts of in a debugger all the time, some gathering and | ||
177 | structuring of events and message passing is useful. | ||
178 | |||
179 | At first, this tool simply makes logs easier to read. Both if viewed in | ||
180 | real-time or taken from disk. Then it also allows to extract all message | ||
181 | passing events from it and forward them to a special process that aggregates | ||
182 | all message passing events and therefore helps you make sense of all the | ||
183 | inter-process communication (IPC) happening between the various pieces of | ||
184 | the GNUnet system beast. | ||
185 | |||
186 | That master process is simply an extra gnunet-logread that you run in a | ||
187 | separate window and adorn it with the '-f' flag. The submitting processes | ||
188 | instead need to be given a '-n' flag. That is because from the GNUnet logs | ||
189 | it isn't clear which process events belong too. For example you may be | ||
190 | having events taking place in the 'util' subsystem of gnunet-psyc-service | ||
191 | just as much as in the 'util' subsystem of gnunet-multicast-service. In | ||
192 | order to make sense of them it is necessary to manually add that info. This | ||
193 | could be remedied by extending the semantics of the GNUNET_log facility | ||
194 | instead, but that is still subject to further consideration. | ||
195 | |||
196 | =head1 AUTHORS | ||
197 | |||
198 | tg & lynX | ||
199 | |||