#! /usr/bin/perl -w

# vim:syntax=perl

use strict;
use lib '/usr/share/perl5';
use Lire::DlfSchema;
use Lire::Program qw(:msg :dlf);
use Lire::Apache qw(modgzip2dlf);

init_dlf_converter( "www" );

my $lines	= 0;
my $dlflines    = 0;
my $errorlines  = 0;
while (<>) {
    chomp;
    $lines++;

    eval {
	my $dlf = modgzip2dlf( $_ );
	print join( " ", @$dlf), "\n";
	$dlflines++;
    };
    if ($@) {
	lr_warn( $@ );
	lr_notice( qq{cannot convert line $. "$_" to www dlf, skipping} );
	$errorlines++;
    }
}
end_dlf_converter( $lines, $dlflines, $errorlines );

__END__

=pod

=head1 NAME

modgzip2dlf - convert Common Log Format with mod_gzip extensions web server log files to DLF

=head1 SYNOPSIS

B<modgzip2dlf> I<file>

=head1 DESCRIPTION

B<modgzip2dlf> converts web server log file in the common log format
with extensions for mod_gzip to www DLF. 

mod_gzip is an Apache extension developed by RemoteCommunications,
Inc. Sourcecode is free available from
http://www.RemoteCommunications.com/apache/mod_gzip/mod_gzip. More
informations can be found at
http://www.RemoteCommunications.com/apache/mod_gzip/mod_gzip_faq.htm.

mod_gzip can log informations about the compression of pages by
configuring Apache to log using the 'gzip' format which can be defined
as follows:

 LogFormat "%h %l %u %t \"%r\" %>s %b %{mod_gzip_result}n %{mod_gzip_compression_ratio}n" gzip

=head1 MOD_GZIP EXTENSIONS

The mod_gzip extensions adds two fields to the Common Log Format; see
common2dlf(1):

  gzip_result compression_ratio

=over 4

=item I<gzip_result>

The B<gzip>'s result code. Usually B<OK>.

=item I<compressio_ratio>

The ratio by which the content was compressed. A number from 0 to 100.

=back

Log example :

  127.0.01 - - [11/03/2001 12:12:01 -0400] "GET / HTTP/1.0" 200 252 "-" "Mozilla/5.0" OK 49
  dsl1.myprovider.com - francis [11/03/2001 12:14:01 -0400] "GET /secret/ HTTP/1.0" 200 300 "http://www.example.com/index.html" "Mozilla/5.0" OK 74

=head1 EXAMPLES

To process a log as produced in the modgzip logformat:

 $ modgzip2dlf < common.log

modgzip2dlf will be rarely used on its own, but is more likely called
by lr_log2report:

 $ lr_log2report modgzip < /var/log/httpd/common.log

=head1 SEE ALSO

common2dlf(1), combined(2), referer2dlf(1)

=head1 AUTHORS

Joost van Baal <joostvb@logreport.org>, Francis J. Lacoste
<flacoste@logreport.org> and Egon Willighagen <egonw@logreport.org>,
based on an idea by Edwin Groothuis

=head1 VERSION

$Id: modgzip2dlf.in,v 1.10 2006/07/23 13:16:36 vanbaal Exp $

=head1 COPYRIGHT

Copyright (C) 2000, 2001 Stichting LogReport Foundation LogReport@LogReport.org

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program (see COPYING); if not, check with
http://www.gnu.org/copyleft/gpl.html.

=cut

# Local Variables:
# mode: cperl
# End:
