#! /usr/bin/perl -w

# vim:syntax=perl

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

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

    eval {
	my $dlf = common2dlf( $_ );
	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

common2dlf - convert Common Log Format web server log files to www DLF

=head1 SYNOPSIS

B<common2dlf> I<file>

=head1 DESCRIPTION

B<common2dlf> converts Common Log Format web server log files to the
www DLF. Common Log Format is a standard log format that was
originally implemented in the CERN httpd web server but that now
supported nowadays by most web servers. Apache, IIS, Boa and PureFTPD
can be configured to log in that format.

=head1 COMMON LOG FORMAT

The Common Log Format has the following format:

I<remotehost> I<rfc931> I<authuser> [I<date>] "I<request>" I<status> I<bytes>

where the fields have the following meaning:

=over 4

=item I<remotehost>

The host that made the request. Can be an IP or a hostname.

=item I<rfc931>

The result of an ident lookup on the host. This is usually never used.

=item I<authuser>

The authenticated username.

=item I<date>

The timestamp of the request.

=item I<request>

The first line of the request. Usually in the format 
"I<method> I<request-uri> I<http-version>".

See also RFC 2616, section 5.1.

=item I<status>

The result status of the request. i.e. 200, 301, 404, 500.

=item I<bytes>

The size of the request sent to the client.

=back

Log example:

  127.0.01 - - [11/03/2001 12:12:01 -0400] "GET / HTTP/1.0" 200 513
  dsl1.myprovider.com - francis [11/03/2001 12:14:01 -0400] "GET /secret/ HTTP/1.0" 200 1256

=head1 SEE ALSO

combined(2), modgzip2dlf(1), 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: common2dlf.in,v 1.8 2002/08/17 01:04:38 flacoste 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 or write to the Free Software 
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.

=cut

# Local Variables:
# mode: cperl
# End:
