#! /usr/bin/perl -w

# vim:syntax=perl

use strict;

use lib '/usr/share/perl5';

use Lire::Program qw/ $PROG /;
use Lire::Logger qw/lr_err lr_info/;
use Lire::DlfStore;
use Lire::ReportConfig;
use Lire::ReportGenerator;

lr_err( "Usage: $PROG <superservice> <report_cfg_file> <dlf_store>" )
  unless @ARGV == 3;

my ( $super, $cfg_file, $storedir ) = @ARGV;

my $report = eval {
    my $cfg = new_from_file Lire::ReportConfig( $super, $cfg_file );
    my $store = Lire::DlfStore->open( $storedir );
    my $generator = new Lire::ReportGenerator( $cfg, $store );
    $generator->generate_report();
};
lr_err( $@ ) if $@;

$report->generator( 'lr_dlf2xml(1), version $Revision: 1.101 $ as shipped with Lire version ' . "$Lire::Config::VERSION");
lr_info( "writing lire XML report..." );
$report->write_report( \*STDOUT );

exit 0;

# Local Variables:
# mode: cperl
# End:

__END__

=pod

=head1 NAME

lr_dlf2xml - generate a XML report from a DLF store.

=head1 SYNOPSIS 

B<lr_dlf2xml> I<superservice> I<report_cfg_file> I<dlf_store>

=head1 DESCRIPTION

B<lr_dlf2xml> generates an XML report on STDOUT, taking DLF data from a Lire
DLF Store.  See lr_store(1) for details on Lire Stores.

It inspects the I<report_cfg_file> (e.g. .../etc/lire/email.cfg) to find
names of reports and associated settings.

The environment variable LR_ID is used in debug messages printed to stderr.
The directory stored in the  environment variable TMPDIR, as set in defaults,
is used to create tmp files in.

This script is normally not called directly from the command line, but called
by lr_log2report(1) via lr_log2xml(1).  (If you really want to call it from
the commandline - e.g. when debugging - you could do something like

 $ export LR_ID=`date +%s`; lr_run lr_dlf2xml www \
    /etc/lire/www.cfg ~/tmp/store/ | lr_run \
    lr_xml2ascii > ~/tmp/www.report

.)

When a Lire report is mentioned in I<report_cfg_file>, it is searched
for in ~/.lire/reports/I<superservice>/ and in
.../share/lire/reports/I<superservice>/ .

When a Lire filter is mentioned in I<report_cfg_file>, using a line with
trailing |, this is searched for in ~/.lire/filters/I<superservice>/ ,
and in .../share/lire/filters/I<superservice>/ .

=head1 SEE ALSO

lr_log2report(1), lr_log2xml(1), lr_store(1), documentation in the Lire User
Manual

=head1 VERSION

$Id: lr_dlf2xml.in,v 1.101 2004/03/23 21:49:37 flacoste Exp $

=head1 COPYRIGHT

Copyright (C) 2001, 2002 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.

=head1 AUTHOR

Francis J. Lacoste <flacoste@logreport.org>

=cut


