README*, config: Removed the version number from these files.
[yaala.git] / yaala
1 #!/usr/bin/perl
2
3 # yaala - Yet Another Advanced Log Analyser
4 # Copyright (C) 2000-2007  Florian octo Forster
5 #
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by the Free
8 # Software Foundation; only version 2 of the license is applicable.
9 #
10 # This program is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13 # more details.
14 #
15 # You should have received a copy of the GNU General Public License along with
16 # this program; if not, write to the Free Software Foundation, Inc., 675 Mass
17 # Ave, Cambridge, MA 02139, USA.
18
19 BEGIN
20 {
21         if ($0 =~ m#^(.*)[/\\]#) { chdir ($1); }
22         
23         unshift (@::INC, 'lib');
24         
25 # 0x010: lib/Data/Core.pm
26 # 0x020: lib/Data/Setup.pm
27 # 0x040: lib/Data/Convert.pm
28 # 0x080: lib/Data/Core.pm (dump any data stored!)
29 # 0x100: lib/Report/GDGraph.pm
30 # 0x200: lib/Data/Persistent.pm
31 # 0x2000: lib/Yaala/Parser/WebserverTools.pm
32
33         $::DEBUG = 0x0000;
34 }
35
36 use strict;
37 use warnings;
38 use vars qw(
39         $DEBUG
40         $EXTRA
41
42         $NAME
43         $VERSION
44         $HOMEPAGE
45 );
46
47 use Carp;
48 use Yaala::Config qw#get_config parse_argv read_config#;
49
50 $NAME = 'yaala';
51 $VERSION = '0.7.3';
52 $HOMEPAGE = 'http://yaala.org/';
53
54 if ($DEBUG)
55 {
56         select STDOUT;
57         $| = 1;
58 }
59
60 $EXTRA = {};
61
62 print STDERR $/, __FILE__, ': $Id: yaala,v 1.17 2004/11/10 10:07:43 octo Exp $' if ($DEBUG);
63
64 parse_argv (@ARGV);
65 read_config (get_config ('config') ? get_config ('config') : 'config');
66
67 unless (get_config ('input'))
68 {
69         usage ();
70         exit (1);
71 }
72
73 # report and data initialization needs parser module
74 my $logtype = get_config ('logtype');
75 my $report  = get_config ('report' );
76 $logtype ||= 'Common';
77 $report  ||= 'Combined';
78 $logtype = ucfirst (lc ($logtype));
79 $report  = ucfirst (lc ($report ));
80
81 require "Yaala/Parser/$logtype.pm";
82 require "Yaala/Report/$report.pm";
83 import Yaala::Parser qw#parse extra#;
84 import Yaala::Report qw#generate#;
85
86 print STDERR $/, __FILE__, ": Accumulating data.." if ($DEBUG);
87
88 my $num_read_files = 0;
89
90 for (get_config ('input'))
91 {
92         #no strict 'refs';
93         if (open (LOGFILE, '< ' . $_))
94         {
95                 print STDERR $/, __FILE__, qq#: Reading "$_"# if ($DEBUG);
96                 $num_read_files++;
97                 
98                 parse ($_) while (<LOGFILE>);
99                 
100                 close LOGFILE;
101         }
102         else
103         {
104                 print STDERR $/, __FILE__, qq#: Error opening "$_": $!#;
105         }
106 }
107 if (!$num_read_files)
108 {
109         print STDERR $/, __FILE__, ": Could not read any files. Exiting.\n";
110         exit (1);
111 }
112
113 extra ();
114
115 print STDERR $/, __FILE__, ': Generating pages..' if ($DEBUG);
116 generate ();
117
118 print STDERR $/, __FILE__, ": Exiting.." if ($DEBUG);
119
120 exit (0);
121
122 ##################################################
123 #    end of main program                         #
124 #---=====================------------------------#
125 # surprised?? well, it's pretty short, cause all #
126 # the _real_ work is done in the the modules.    #
127 # If you write a modul by your own: PLEASE send  #
128 # me a copy so that i can include it in the      #
129 # package.                                       #
130 # And how about 12 modules at a time ? -- qmax   #
131 # Awesome :) -- octo                             #
132 ##################################################
133
134 sub usage
135 {
136         print STDOUT <<EOF;
137
138 Usage: $0 [--<key> <value>] file1 .. fileN
139
140 Options:
141         --config        Specify alternate config file
142         --directory     yaala will write all generated files to this
143                         directory (and overwrite existing ones without
144                         prompting!)
145         --report        Selects the report type to use
146         --logtype       Specifies the type of logfiles to parse
147         --select        Select statements. See README.selections
148
149 You can prepend two dashes to every keyword in the config file and
150 configure yaala from the command line.
151 EOF
152         return (1);
153 }
154
155 END
156 {
157         print STDERR $/ if ($DEBUG);
158 }