| 1 | #!/usr/local/bin/perl -w | ||
| 2 | # Copyright (c) 2002-2005 the World Wide Web Consortium : | ||
| 3 | # Keio University, | ||
| 4 | # Institut National de Recherche en Informatique et Automatique, | ||
| 5 | # Massachusetts Institute of Technology. | ||
| 6 | # written by Olivier Thereaux <ot@w3.org> for W3C | ||
| 7 | # | ||
| 8 | # $Id: logprocess.pl,v 1.10 2005/09/09 06:33:11 ot Exp $ | ||
| 9 | ######################### | ||
| 10 | |||
| 11 | use strict; | ||
| 12 | use Getopt::Long qw(GetOptions); | ||
| 13 | use W3C::LogValidator (); | ||
| 14 | |||
| 15 | my $conffile = ''; | ||
| 16 | my %conf; | ||
| 17 | my $OutputTo; | ||
| 18 | my $SendTo; | ||
| 19 | $conf{"verbose"}=1; | ||
| 20 | |||
| 21 | GetOptions('q|quiet' => sub { $conf{"verbose"} = 0; }, | ||
| 22 | 'v|verbose' => sub { $conf{"verbose"} = 2; }, | ||
| 23 | 'd|debug' => sub { $conf{"verbose"} = 3; }, | ||
| 24 | 'f|config=s' => \$conffile, | ||
| 25 | 'help|h|?' => sub { usage(1); exit 0 }, | ||
| 26 | 'HTML' => sub { $conf{"UseOutputModule"} = "W3C::LogValidator::Output::HTML"; }, | ||
| 27 | 'email' => sub { $conf{"UseOutputModule"} = "W3C::LogValidator::Output::Mail"; }, | ||
| 28 | 'o|output=s' => \$OutputTo, | ||
| 29 | 's|sendto=s' => \$SendTo | ||
| 30 | ) or usage(1); | ||
| 31 | |||
| 32 | $conf{"OutputTo"} = $OutputTo if ($OutputTo); | ||
| 33 | $conf{"ServerAdmin"} = $SendTo if ($SendTo); | ||
| 34 | |||
| 35 | W3C::LogValidator->new($conffile, \%conf)->process(); | ||
| 36 | |||
| 37 | sub usage | ||
| 38 | { | ||
| 39 | print "Usage: logprocess.pl [options] | ||
| 40 | |||
| 41 | |||
| 42 | General options are: | ||
| 43 | -h/--help help. what you're reading now. | ||
| 44 | -f/--config <filename> to read a specific config file. strongly suggested. | ||
| 45 | |||
| 46 | Verbosity options are (default - no option - is between quiet and verbose): | ||
| 47 | -q/--quiet quiet. not verbose. useful for cron'd usage. | ||
| 48 | -v/--verbose verbose. lots of blah blah. | ||
| 49 | -d/--debug even more verbose than verbose, for debug purpose. | ||
| 50 | |||
| 51 | Output choices are (default - nothing specified - is command-line output): | ||
| 52 | --HTML trigger output in HTML | ||
| 53 | --email trigger output as mail sent to maintainer | ||
| 54 | -o/--output <filename> choose where to save output | ||
| 55 | the output will go to console if not specified | ||
| 56 | -s/--sendto <email> choose where to send the e-mail | ||
| 57 | In e-mail output mode, if neither this nor ServerAdmin (in the config) | ||
| 58 | is specified then the output will fall-back to console | ||
| 59 | |||
| 60 | |||
| 61 | Note: | ||
| 62 | All these options can be configured through the config file. | ||
| 63 | Setting an option overrides the choice made in the config file. | ||
| 64 | |||
| 65 | "; | ||
| 66 | exit 0; | ||
| 67 | } |