moseley 2002/06/30 15:32:18 Modified: src/search swish.cgi Log: Add better warning for errors while parsing the config file. Revision Changes Path 1.8 +28 -8 modperl-docs/src/search/swish.cgi Index: swish.cgi =================================================================== RCS file: /home/cvs/modperl-docs/src/search/swish.cgi,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- swish.cgi 6 Apr 2002 14:42:26 -0000 1.7 +++ swish.cgi 30 Jun 2002 22:32:17 -0000 1.8 @@ -523,15 +523,29 @@ sub merge_read_config { my $config = shift; + set_default_debug_flags(); set_debug($config); # get from config or from %ENV + 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}; - return $config unless ref $return eq 'HASH'; + unless ( ref $return eq 'HASH' ) { + log_msg("Config file '$config->{config_file}': $! $@" ); + return $config; + } + if ( $config->{debug} || $return->{debug} ) { require Data::Dumper; @@ -548,6 +562,12 @@ } #-------------------------------------------------------------------------------------------------- +sub log_msg { + my $time = scalar localtime; + warn "$time\t", @_; +} + +#-------------------------------------------------------------------------------------------------- sub set_default_debug_flags { # Debug flags defined @@ -680,7 +700,7 @@ eval { require $file }; if ( $@ ) { - warn "$0 [EMAIL PROTECTED]"; + log_msg( "$0 $@"); print <<EOF; Content-Type: text/html @@ -853,7 +873,7 @@ }; if ( $@ ) { - warn "$0 $@"; # if $conf->{debug}; + log_msg("$0 $@"); # if $conf->{debug}; $self->errstr( "Service currently unavailable" ); return $self; } @@ -1385,7 +1405,7 @@ eval { require "$package.pm" }; if ( $@ ) { $self->errstr( "Failed to load Highlighting Module - check error log" ); - warn "$0: $@"; + log_msg("$0: $@"); $highlight = ''; next; } else { @@ -1463,7 +1483,7 @@ unless ( exec $self->{prog}, $self->swish_command ) { - warn "Child process Failed to exec '$self->{prog}' Error: $!"; + log_msg("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]