Man page: Move the description of --info=progress2 to a better place.
[rsync/rsync.git] / support / logfilter
CommitLineData
bf485d3d 1#!/usr/bin/perl
49356846
WD
2# Filter the rsync daemon log messages by module name. The log file can be
3# in either syslog format or rsync's own log-file format. Note that the
4# MODULE_NAME parameter is used in a regular-expression match in order to
5# allow regex wildcards to be used. You can also limit the output by
6# directory hierarchy in a module. Examples:
7#
8# logfilter foo /var/log/rsyncd.log # output lines for module foo
9# logfilter foo/dir /var/log/syslog # limit lines to those in dir of foo
bf485d3d
WD
10
11use strict;
12
13my $match = shift;
14die "Usage: logfilter MODULE_NAME [LOGFILE ...]\n" unless defined $match;
15
16my $syslog_prefix = '\w\w\w +\d+ \d\d:\d\d:\d\d \S+ rsyncd';
17my $rsyncd_prefix = '\d\d\d\d/\d\d/\d\d \d\d:\d\d:\d\d ';
18
19my %pids;
20
21while (<>) {
22 my($pid,$msg) = /^(?:$syslog_prefix|$rsyncd_prefix)\[(\d+)\]:? (.*)/o;
23 next unless defined $pid;
24 my($mod_spec) = $msg =~ /^rsync (?:on|to) (\S+) from /;
25 if (defined $mod_spec) {
26 if ($mod_spec =~ /^$match(\/\S*)?$/o) {
27 $pids{$pid} = 1;
28 } else {
29 delete $pids{$pid};
30 }
31 }
32 next unless $pids{$pid};
33 print $_;
34}