#!/usr/bin/perl -w

#$Header: /home2/cvsroot/LogTrend/Visu/LogTrendVisu,v 1.6 2001/11/20 16:28:31 lsimonneau Exp $
##******************************************************************************
## Visu
##  Description  : LogTrend visu tool
##  Project      : LogTrend 1.0.0.0 - Atrid Systemes
##  Author       : Sylvain Lhullier s.lhullier@atrid.fr
##******************************************************************************
#$Log: LogTrendVisu,v $
#Revision 1.6  2001/11/20 16:28:31  lsimonneau
#Change use Getopt::Long for more compatibility with standard debian potato packages.
#
#Revision 1.5  2001/10/18 15:22:57  slhullier
#Inheritance for report/web
#
#Revision 1.4  2001/09/27 16:06:40  slhullier
#Configuration by XML file works.
#
#Revision 1.3  2001/08/17 09:29:35  slhullier
#
#Zoom navigation work for value-boundaries not set
#
#Revision 1.2  2001/07/27 09:56:20  slhullier
#*** empty log message ***
#
#Revision 1.1  2001/07/27 07:48:06  slhullier
#*** empty log message ***
#

use strict;
use Getopt::Long;
use LogTrend::Visu::Web::ManagersCreator;
use LogTrend::Visu::Constants;

my $defaultConfFile = "/etc/logtrend/Visu/configuration.xml";
my $g_name = $0;

##******************************************************************************
## Function display_help_and_exit
##******************************************************************************
sub display_help_and_exit
{
   my $status = shift;
   print "\n",
         "Usage: $g_name [--Daemon|-D] [--file|f confFile]\n",
         "       $g_name --help|h\n",
         "Options :\n",
         "   -D : run as daemon (detach form terminal, syslog...).\n",
         "   -f : configuration file name (default=$defaultConfFile).\n",
         "\n";

   exit( $status );
}

##******************************************************************************
## Function main
##******************************************************************************
sub main
{
   my $opts = {};

   Getopt::Long::Configure("bundling", "no_ignore_case");

   GetOptions($opts, 'Daemon|D', 'file|f=s', 'help|h' ) or
      display_help_and_exit(1);
   display_help_and_exit(0) if(exists($opts->{help}));

   my $file = $defaultConfFile;
   $file = $opts->{file} if(exists($opts->{file}));

   my $mc = new LogTrend::Visu::Web::ManagersCreator( $file );
   $mc->daemon_mode() if( exists($opts->{Daemon}) and $opts->{Daemon} == 1);

   $mc->run();   # Should never end

}

##******************************************************************************
main();

