
From leo@strike.wu-wien.ac.at Fri Oct  2 09:38:54 1998
Date: Fri, 2 Oct 1998 15:48:19 +0200 (MES)
From: Alexander Bergolth <leo@strike.wu-wien.ac.at>
To: htdig@sdsu.edu
Subject: htdig: htsearch: syslogging patch

Hi!

I have modified Jason Moores Patch
(http://www.htdig.org/mail/1998-04/0087.html)
to write the search info into syslog. This eliminates the need of locking
the log-file.

Additionally I moved it into Display.cc so that the number of search
results is displayed correctly if the search is restricted.

To enable it, add the following line to your .conf file:
logging: true

log-facility is LOG_LOCAL5. To log into a separate file add the following
to your syslog.conf:
local5.debug: /var/log/htsearch.log
... and restart syslogd.

---------- snipp! ----------

--- htdig-3.1.0b1/htsearch/Display.cc	Wed Sep 30 19:09:00 1998
+++ htdig-3.1.0b1-new/htsearch/Display.cc	Fri Oct  2 14:38:38 1998
@@ -73,6 +73,7 @@
 #include <fstream.h>
 #include <stdio.h>
 #include <ctype.h>
+#include<syslog.h>
 
 
 //*****************************************************************************
@@ -130,6 +131,11 @@
     int			number = config.Value("matches_per_page");
     int			startAt = (pageNumber - 1) * number;
 
+    if (config.Boolean("logging"))
+    {
+        logSearch(pageNumber, matches);
+    }
+
     setVariables(pageNumber, matches);
 	
     //
@@ -925,3 +931,22 @@
 }
 
 
+void
+Display::logSearch(int page, List *matches)
+{
+    char	*env_host;
+    time_t	t;
+    int		nMatches = 0;
+
+    if (matches)
+	nMatches = matches->Count();
+
+    openlog("htsearch", LOG_PID, LOG_LOCAL5);
+    syslog(LOG_NOTICE, "%s [%s] (%s) [%s] [%s] (%d/%s) - %d\n",
+	   getenv("REMOTE_HOST"),
+	   input->exists("config") ? input->get("config") : "default",
+	   config["match_method"], input->get("words"), logicalWords.get(),
+	   nMatches, config["matches_per_page"],
+	   page
+	   );
+}
--- htdig-3.1.0b1/htsearch/Display.h	Wed Sep 30 19:09:30 1998
+++ htdig-3.1.0b1-new/htsearch/Display.h	Fri Oct  2 14:38:49 1998
@@ -155,6 +155,7 @@
     void		displayParsedFile(char *);
     void		setVariables(int, List *);
     void		createURL(String &, int);
+    void		logSearch(int, List *);
 };
 
 //*****************************************************************************

---------- snipp! ----------

-----------------------------------------------------------------------
Alexander (Leo) Bergolth                          leo@leo.wu-wien.ac.at
WU-Wien - Zentrum fuer Informatikdienste       http://leo.wu-wien.ac.at
Info Center
In a world without walls and fences, who needs windows and gates?

----------------------------------------------------------------------
To unsubscribe from the htdig mailing list, send a message to
htdig-request@sdsu.edu containing the single word "unsubscribe" in
the body of the message.
