moseley 2002/06/30 22:08:44
Modified: src/search swish.cgi
Log:
Take Stas' advice about warnings...
Revision Changes Path
1.9 +22 -25 modperl-docs/src/search/swish.cgi
Index: swish.cgi
===================================================================
RCS file: /home/cvs/modperl-docs/src/search/swish.cgi,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- swish.cgi 30 Jun 2002 22:32:17 -0000 1.8
+++ swish.cgi 1 Jul 2002 05:08:43 -0000 1.9
@@ -9,7 +9,7 @@
### It should point to the location of the
### associated script modules directory
-
+my $DEFAULT_CONFIG_FILE = '.swishcgi.conf';
###################################################################################
#
@@ -142,7 +142,7 @@
# By default, this script tries to read a config file. You should
probably
# comment this out if not used save a disk stat
- config_file => '.swishcgi.conf', # Default config file
+ config_file => $DEFAULT_CONFIG_FILE, # Default config file
# The location of your index file. Typically, this would not be in
@@ -531,22 +531,24 @@
return $config unless $config->{config_file};
- unless ( -e $config->{config_file} ) {
- # If any debugging messages set report this -- there's a default
normally set
- # so don't want to always report, although would be nice to avoid
the stat()
- log_msg("Config file '$config->{config_file}': $!")
- if $config->{debug};
- return $config;
- }
-
- my $return = do $config->{config_file};
+ my $return = do $config->{config_file}; # load the config file
unless ( ref $return eq 'HASH' ) {
- log_msg("Config file '$config->{config_file}': $! $@" );
- return $config;
+
+ # First, let's check for file not found for the default config,
which we can ignore
+
+ my $error = $@ || $!;
+
+ if ( $config->{config_file} eq $DEFAULT_CONFIG_FILE && !-e
$config->{config_file} ) {
+ warn "Config file '$config->{config_file}': $!" if
$config->{debug};
+ return $config;
+ }
+
+ die "Config file '$config->{config_file}': $error";
}
+
if ( $config->{debug} || $return->{debug} ) {
require Data::Dumper;
print STDERR "\n---------- Read config parameters from
'$config->{config_file}' ------\n",
@@ -561,11 +563,6 @@
return { %$config, %$return };
}
-#--------------------------------------------------------------------------------------------------
-sub log_msg {
- my $time = scalar localtime;
- warn "$time\t", @_;
-}
#--------------------------------------------------------------------------------------------------
sub set_default_debug_flags {
@@ -700,7 +697,7 @@
eval { require $file };
if ( $@ ) {
- log_msg( "$0 $@");
+ warn "$0 $@";
print <<EOF;
Content-Type: text/html
@@ -873,7 +870,7 @@
};
if ( $@ ) {
- log_msg("$0 $@"); # if $conf->{debug};
+ warn "$0 $@"; # if $conf->{debug};
$self->errstr( "Service currently unavailable" );
return $self;
}
@@ -1405,7 +1402,7 @@
eval { require "$package.pm" };
if ( $@ ) {
$self->errstr( "Failed to load Highlighting Module -
check error log" );
- log_msg("$0: $@");
+ warn "$0: $@";
$highlight = '';
next;
} else {
@@ -1483,7 +1480,7 @@
unless ( exec $self->{prog}, $self->swish_command ) {
- log_msg("Child process Failed to exec '$self->{prog}' Error:
$!");
+ warn "Child process Failed to exec '$self->{prog}' Error: $!";
print "Failed to exec Swish"; # send this message to parent.
exit;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]