#! /usr/bin/perl -w

use strict;

use lib '/usr/local/share/perl5';

use Locale::TextDomain 'lire';

# use Lire::Error qw/ missing_argument_usage /;
use Lire::LrCommand;

my $prog = new Lire::LrCommand();
$prog->init();
$prog->add_report_options();
$prog->add_output_format_options();
$prog->add_common_options();

$prog->set_usage( __( '[<output options>] <dlf_converter> [<log_file> [<report_destination>]]' ) );
$prog->set_help( __( 'Converts <log_file> using <dlf_converter> and generate a report in <report_destination>.' ) );
$prog->parse_options();

my ( $converter, $logfile, $output_file ) = @ARGV;
$prog->usage( 'dlf_converter' )
  unless defined $converter;
$logfile = '-' unless defined $logfile;
$output_file = '-' unless defined $output_file;

$prog->check_output_format();
my $report = $prog->generate_report( $converter, $logfile );
$prog->format_report( $report, $output_file );

exit(0);

__END__

=pod

=head1 NAME

lr_log2report - generates a report from a log file

=head1 SYNOPSIS

B<lr_log2report> B<[>I<options>B<]> I<dlf_converter> B<[> I<logfile> B<]> B<[> I<output_file> B<]>

B<lr_log2report> B<--version>

B<lr_log2report> B<--help> B<[dlf-converters|output-formats|report-templates]>

=head1 OPTIONS

=over 4

=item B<--help> B<[>I<section>B<]>

If no argument is given, prints usage information and exits. Argument
can be one of the following:

=over 4

=item dlf-converters

Prints the list of available DLF converters and exits.

=item output-formats

Prints the list of available output formats and exits.

=item report-templates

Prints the list of available report templates and exits.

=back

=item B<--version>

Prints Lire's version and exits.

=item B<--output-format|-o> I<output format>

Selects the ouput format in which to generate the report. 

=item B<--template|-t> I<name>

Uses the report configuration named I<name> to generate the report. 

=back

=head1 DESCRIPTION

B<lr_log2report> reads a log file from STDIN or the specified argument
and will output a formatted Lire report on STDOUT or in the
I<output_file> argument. The format of the log file is specified using
the I<dlf_converter> argument. Use the B<--help dlf-converters> option
to get a list of all currently available DLF converters.

In case the log is passed in a compressed format, it's uncompressed on the fly,
using gzip(1).

WARNING: This command outputs binary data on the terminal for all
output formats except B<txt> and B<xml>. You should redirect
stdout to a file when using those output formats.

In the case where I<output format> is B<html>, the I<output_file> argument will
be interpreted as a directory name.  This directory will get created if needed,
and will hold the various html files.  In case this argument is omitted, a
tar(1) file should be output on STDOUT (but see the BUGS section).

WARNING: Running this command on big logfiles generally means you'll need
lots of free diskspace.  See Lire::LrCommand(3pm) for details.

=head1 EXAMPLES

To process a Postfix log and display the report as text, use

 $ lr_log2report postfix /var/log/mail.log

To process a Postfix log and create an HTML report in a directory, use

 $ lr_log2report -o html postfix /var/log/mail.log postfix-report

=head1 BUGS

If

 --output html

is specified, both I<logfile> and I<output_file> need to be specified.
Specifying C<-> (or C</dev/stdin>) as I<logfile> is supported.  So this

 $ tai64nfrac < /var/log/qmail-send/current | \
    lr_log2report qmail --output html - /tmp/report

will work.

=head1 SEE ALSO

lr_log2mail(1), lr_xml2report(1), lr_xml2mail(1), lire(1), lire(7),
Lire::LrCommand(3pm), documentation in the Lire User Manual

=head1 AUTHORS

  Joost van Baal <joostvb@logreport.org>
  Francis J. Lacoste <flacoste@logreport.org>

=head1 VERSION

$Id: lr_log2report.in,v 1.100 2006/10/04 10:19:17 vanbaal Exp $

=head1 COPYRIGHT

Copyright (C) 2000-2004 Stichting LogReport Foundation LogReport@LogReport.org

This program is part of Lire.

Lire 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:

