![]() |
![]()
| ![]() |
![]()
NAMEHTTPD::Log::Filter - a module to filter entries out of an httpd log. SYNOPSISmy $hlf = HTTPD::Log::Filter->new( exclusions_file => $exclusions_file, agent_re => '.*Mozilla.*', format => 'ELF', ); while( <> ) { my $ret = $hlf->filter( $_ ); die "Error at line $.: invalid log format\n" unless defined $ret; print $_ if $ret; } print grep { $hlf->filter( $_ ) } <>; $hlf = HTTPD::Log::Filter->new( capture => [ qw( host ident authexclude date request status bytes ) ]; ); while( <> ) { next unless $hlf->filter( $_ ); print $hlf->host, "\n"; } print grep { $hlf->filter( $_ ) } <>; DESCRIPTIONThis module provide a simple interface to filter entries out of an httpd logfile. The constructor can be passed regular expressions to match against particular fields on the logfile. It does its filtering line by line, using a filter method that takes a line of a logfile as input, and returns true if it matches, and false if it doesn't. There are two possible non-matching (false) conditions; one is where the line is a valid httpd logfile entry, but just doesn't happen to match the filter (where "" is returned). The other is where it is an invalid entry according to the format specified in the constructor. CONSTRUCTORThe constructor is passed a number of options as a hash. These are:
METHODSfilterFilters a line of a httpd logfile. returns true (the line) if it matches, and false ("" or undef) if it doesn't. There are two possible non-matching (false) conditions; one is where the line is a valid httpd logfile entry, but just doesn't happen to match the filter (where "" is returned). The other is where it is an invalid entry according to the format specified in the constructor. reReturns the current filter regular expression. formatReturns the current format. (host|ident|authexclude|date|request|status|bytes|referer|agent|junk)If the capture option has been specified, these methods return the captured string for each field as a result of the previous call to filter. AUTHORAve Wrigley <Ave.Wrigley@itn.co.uk> COPYRIGHTCopyright (c) 2001 Ave Wrigley. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|