Skip to main content.
home | support | download

Back to List Archive

Re: Almost

From: Roman Chyla <chyla(at)not-real.knihovnabbb.cz>
Date: Tue Jul 20 2004 - 13:01:22 GMT
Hi, I am using a procedure in the template, it is run after searching was
finished and stores it into the file, but DB is also possible
roman

this command from the sub show_template() starts it

sub show_template {
.
.
zapis_log( $results) if ($q->param('submit') &&
$results->config('log_file'));
}

----------------------------------
you will also need to add a directive to the configuration file:

log_file => 'reglog.log',

----------------------------------
output is like this (of course, you may change it, in fact, you must because
form_type is not in Templates* ):

form_type | simple_query | number_of_hits | date | search_time | run_time |
http_browser | resolved_complex_query

1 žižl*   464 Mon Jul 19 08:43:04 2004 0.894 seconds 0.947 seconds
Mozilla/4.0 (compatible; MSIE 6.0; Windows 98) Opera 7.10  [en] au=(žižl*)
OR ti=(žižl*) OR kw=(žižl*) OR kw=(žižl*) OR src=(žižl*) OR idd=(žižl*) OR
mdt=(žižl*) OR swishdocpath=(žižl*)
0 židle   -1 Mon Jul 19 13:38:01 2004 0 0 Mozilla/4.0 (compatible; MSIE 6.0;
Windows NT 5.1) kw=(židle)

----------------------------------
here goes procedure:

sub zapis_log{
 my ($results) = @_;
 my $q = $results->CGI;


 my $logfile = $results->config('log_file');
 my $bigf =  $q->{bigf}[0] || '0';
 my $query = $results->{query_simple} || '--?!--';
 my $query_complex = $results->{swish_command}[1] || '';
 my $hits = $results->navigation('hits') || '-1';
 my $search_time = $results->navigation('search_time') || 0;
 my $run_time = $results->navigation('run_time') || 0;
 #my $referer = $q->referer;
 my $browser = $q->http('HTTP_USER_AGENT');
 my $date = localtime(time);

 my $message = sprintf("%s\t%-
30s\t%6d\t%s\t%s\t%s\t%s\t%s\n",$bigf,$query,$hits,$date,$search_time,$run_t
ime,$browser,$query_complex);
 print STDERR "logfile $logfile\n$message";

 open(LOG, ">>", "$logfile")  or die "can't open filename: $!";

 my $fh = $^O =~ /Win32/i;
 if ($fh){

 }else{
  use Fcntl qw(:DEFAULT :flock);
  unless (flock(LOG, LOCK_EX)) {
  $| = 1;
  print STDERR "Waiting for $logfile lock $date...";
  flock(FH, LOCK_EX)  or exit "can't lock filename: $!";
  }
 }

   print LOG "$message";
   $fh ? () : flock(LOG,LOCK_UN);
   close LOG;


}


----- Original Message ----- 
From: "John Wentworth" <john@sysful.com>
To: "Multiple recipients of list" <swish-e@sunsite3.berkeley.edu>
Sent: Friday, July 16, 2004 7:11 PM
Subject: [SWISH-E] Almost


> Thomas Dowling wrote:
>
> >I basically like the contents of the swish.cgi script for search
> >and I do not want to modify it alot but I would like to add one feature =
> =3D
> >I would like the drop the search terms and the result of the search =
> into =3D
> >a database to analyze what our customers are searching for
> >I don't really know perl but I figure I should be able to hack =
> something =3D
> >together with some tutorials I found
> >what I basically need to information as to which perl variables in this =
> =3D
> >script correspond to that information and where would be a good place =
> to =3D
> >insert this code since I'm having trouble following the code
> >
> > =20
> >
>
> I don't use swish.cgi myself, so apologies if I'm off base.  But if=20
> swish.cgi uses HTTP GET requests, the search terms have probably in your =
>
> web transaction log all along.  Log analysis software, a simple Perl=20
> script, or grep could all fish them out for you without editing the CGI=20
> script.  I'm guessing you're looking for lines that match something like =
>
> "GET /somewhere/swish.cgi?query=3Dmy+search+terms....".
>
>
> Thomas Dowling
> tdowling@ohiolink.edu
>
> This is a good suggestion however doesn't fully solve the problem =
> because it doesn't record whether the search was successful or not. =
> Which is why I thought I had to try to accomplish this in the cgi =
> script.
>
>
>
> *********************************************************************
> Due to deletion of content types excluded from this list by policy,
> this multipart message was reduced to a single part, and from there
> to a plain text message.
> *********************************************************************
>
>
Received on Tue Jul 20 06:01:45 2004