changeset 3162:153681321f8c

logging: use module-level logger for MoinMoin.search.*
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 02 Mar 2008 01:00:14 +0100
parents 5a304e55a945
children 1662ed80fbae
files MoinMoin/search/__init__.py MoinMoin/search/builtin.py MoinMoin/search/queryparser.py
diffstat 3 files changed, 36 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/search/__init__.py	Sun Mar 02 00:02:08 2008 +0100
+++ b/MoinMoin/search/__init__.py	Sun Mar 02 01:00:14 2008 +0100
@@ -10,6 +10,9 @@
     @license: GNU GPL, see COPYING for details
 """
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 from MoinMoin.search.queryparser import QueryParser
 from MoinMoin.search.builtin import Search
 
--- a/MoinMoin/search/builtin.py	Sun Mar 02 00:02:08 2008 +0100
+++ b/MoinMoin/search/builtin.py	Sun Mar 02 01:00:14 2008 +0100
@@ -5,12 +5,15 @@
     @copyright: 2005 MoinMoin:FlorianFesti,
                 2005 MoinMoin:NirSoffer,
                 2005 MoinMoin:AlexanderSchremmer,
-                2006-2007 MoinMoin:ThomasWaldmann,
+                2006-2008 MoinMoin:ThomasWaldmann,
                 2006 MoinMoin:FranzPletz
     @license: GNU GPL, see COPYING for details
 """
 
-import time, os, errno, codecs, logging
+import time, os, errno, codecs
+
+from MoinMoin import log
+logging = log.getLogger(__name__)
 
 from MoinMoin import wikiutil, config
 from MoinMoin.Page import Page
@@ -380,11 +383,10 @@
             except wikiutil.PluginMissingError:
                 pass
             else:
-                logging.info("Cannot load filter for mimetype." + modulename)
+                logging.info("Cannot load filter for mimetype %s" % modulename)
         try:
             data = execute(self, filename)
-            #if debug:
-            #    logging.info("Filter %s returned %d characters for file %s" % (modulename, len(data), filename))
+            logging.debug("Filter %s returned %d characters for file %s" % (modulename, len(data), filename))
         except (OSError, IOError), err:
             data = ''
             logging.warning("Filter %s threw error '%s' for file %s" % (modulename, str(err), filename))
@@ -454,15 +456,15 @@
         start = time.time()
         if self.request.cfg.xapian_search:
             hits = self._xapianSearch()
-            logging.debug("search: _xapianSearch found %d hits" % len(hits))
+            logging.debug("_xapianSearch found %d hits" % len(hits))
         else:
             hits = self._moinSearch()
-            logging.debug("search: moinSearch found %d hits" % len(hits))
+            logging.debug("_moinSearch found %d hits" % len(hits))
 
         # important - filter deleted pages or pages the user may not read!
         if not self.filtered:
             hits = self._filter(hits)
-            logging.debug("search: after filtering: %d hits" % len(hits))
+            logging.debug("after filtering: %d hits" % len(hits))
 
         # when xapian was used, we can estimate the numer of matches
         # Note: hits can't be estimated by xapian with historysearch enabled
@@ -522,20 +524,20 @@
                     description = query.get_description() # deprecated since xapian 1.0, removal in 1.1
                 except AttributeError:
                     description = str(query)
-                logging.info("xapianSearch: query = %r" % description)
+                logging.debug("_xapianSearch: query = %r" % description)
                 query = xapwrap.index.QObjQuery(query)
                 enq, mset, hits = index.search(query, sort=self.sort,
                         historysearch=self.historysearch)
                 clock.stop('_xapianQuery')
 
-                #logging.info("xapianSearch: finds: %r" % hits)
+                logging.debug("_xapianSearch: finds: %r" % hits)
                 def dict_decode(d):
                     """ decode dict values to unicode """
                     for key in d:
                         d[key] = d[key].decode(config.charset)
                     return d
                 pages = [dict_decode(hit['values']) for hit in hits]
-                logging.info("xapianSearch: finds pages: %r" % pages)
+                logging.debug("_xapianSearch: finds pages: %r" % pages)
 
                 self._xapianEnquire = enq
                 self._xapianMset = mset
@@ -624,7 +626,7 @@
 
     def _getHits(self, pages, matchSearchFunction):
         """ Get the hit tuples in pages through matchSearchFunction """
-        logging.debug("search: _getHits searching in %d pages ..." % len(pages))
+        logging.debug("_getHits searching in %d pages ..." % len(pages))
         hits = []
         revisionCache = {}
         fs_rootpage = self.fs_rootpage
@@ -639,7 +641,7 @@
             wikiname = valuedict['wikiname']
             pagename = valuedict['pagename']
             attachment = valuedict['attachment']
-            logging.debug("search: _getHits processing %r %r %r" % (wikiname, pagename, attachment))
+            logging.debug("_getHits processing %r %r %r" % (wikiname, pagename, attachment))
 
             if 'revision' in valuedict and valuedict['revision']:
                 revision = int(valuedict['revision'])
@@ -660,7 +662,7 @@
                         hits.append((wikiname, page, attachment, matches))
                 else:
                     matches = matchSearchFunction(page=page, uid=uid)
-                    logging.debug("search: matchSearchFunction %r returned %r" % (matchSearchFunction, matches))
+                    logging.debug("matchSearchFunction %r returned %r" % (matchSearchFunction, matches))
                     if matches:
                         if not self.historysearch and \
                                 pagename in revisionCache and \
--- a/MoinMoin/search/queryparser.py	Sun Mar 02 00:02:08 2008 +0100
+++ b/MoinMoin/search/queryparser.py	Sun Mar 02 01:00:14 2008 +0100
@@ -5,13 +5,15 @@
     @copyright: 2005 MoinMoin:FlorianFesti,
                 2005 MoinMoin:NirSoffer,
                 2005 MoinMoin:AlexanderSchremmer,
-                2006-2007 MoinMoin:ThomasWaldmann,
+                2006-2008 MoinMoin:ThomasWaldmann,
                 2006 MoinMoin:FranzPletz
     @license: GNU GPL, see COPYING for details
 """
 
 import re
-import logging
+
+from MoinMoin import log
+logging = log.getLogger(__name__)
 
 from MoinMoin import config, wikiutil
 from MoinMoin.search.results import Match, TitleMatch, TextMatch
@@ -151,7 +153,7 @@
                         break
                     elif t is True:
                         result = True
-                logging.debug("search: pageFilter AND returns %r" % result)
+                logging.debug("pageFilter AND returns %r" % result)
                 return result
             return filter
 
@@ -251,7 +253,7 @@
                         return True
                     elif t is False:
                         result = False
-                logging.debug("search: pageFilter OR returns %r" % result)
+                logging.debug("pageFilter OR returns %r" % result)
                 return result
             return filter
 
@@ -310,7 +312,7 @@
         return u"(%s)" % self._pattern
 
     def search(self, page):
-        logging.debug("search: TextSearch searching page %r for (negated = %r) %r" % (page.page_name, self.negated, self._pattern))
+        logging.debug("TextSearch searching page %r for (negated = %r) %r" % (page.page_name, self.negated, self._pattern))
         matches = []
 
         # Search in page name
@@ -352,7 +354,7 @@
                 result = matches
             else:
                 result = None
-        logging.debug("search: TextSearch returning %r" % result)
+        logging.debug("TextSearch returning %r" % result)
         return result
 
     def xapian_wanted(self):
@@ -432,13 +434,13 @@
         def filter(name):
             match = self.search_re.search(name)
             result = bool(self.negated) ^ bool(match)
-            logging.debug("search: pageFilter title returns %r (%r)" % (result, self.pattern))
+            logging.debug("pageFilter title returns %r (%r)" % (result, self.pattern))
             return result
         return filter
 
     def search(self, page):
         """ Get matches in page name """
-        logging.debug("search: TitleSearch searching page %r for (negated = %r) %r" % (page.page_name, self.negated, self._pattern))
+        logging.debug("TitleSearch searching page %r for (negated = %r) %r" % (page.page_name, self.negated, self._pattern))
         matches = []
         for match in self.search_re.finditer(page.page_name):
             if page.request.cfg.xapian_stemming:
@@ -471,7 +473,7 @@
                 result = matches
             else:
                 result = None
-        logging.debug("search: TitleSearch returning %r" % result)
+        logging.debug("TitleSearch returning %r" % result)
         return result
 
     def xapian_wanted(self):
@@ -575,7 +577,7 @@
 
     def search(self, page):
         # Get matches in page links
-        logging.debug("search: LinkSearch searching page %r for (negated = %r) %r" % (page.page_name, self.negated, self._pattern))
+        logging.debug("LinkSearch searching page %r for (negated = %r) %r" % (page.page_name, self.negated, self._pattern))
         matches = []
         Found = True
 
@@ -605,7 +607,7 @@
                 result = matches
             else:
                 result = None
-        logging.debug("search: LinkSearch returning %r" % result)
+        logging.debug("LinkSearch returning %r" % result)
         return result
 
     def xapian_wanted(self):
@@ -665,7 +667,7 @@
         return ""
 
     def search(self, page):
-        logging.debug("search: LanguageSearch searching page %r for (negated = %r) %r" % (page.page_name, self.negated, self._pattern))
+        logging.debug("LanguageSearch searching page %r for (negated = %r) %r" % (page.page_name, self.negated, self._pattern))
         match = False
         body = page.getPageHeader()
 
@@ -688,7 +690,7 @@
                 result = [Match()] # represents "matched" (but we have nothing to show)
             else:
                 result = None
-        logging.debug("search: LanguageSearch returning %r" % result)
+        logging.debug("LanguageSearch returning %r" % result)
         return result
 
     def xapian_wanted(self):
@@ -861,7 +863,7 @@
         return ""
 
     def search(self, page):
-        logging.debug("search: DomainSearch searching page %r for (negated = %r) %r" % (page.page_name, self.negated, self._pattern))
+        logging.debug("DomainSearch searching page %r for (negated = %r) %r" % (page.page_name, self.negated, self._pattern))
         checks = {'underlay': page.isUnderlayPage,
                   'standard': page.isStandardPage,
                   'system': lambda page=page: wikiutil.isSystemPage(page.request, page.page_name),
@@ -883,7 +885,7 @@
                 result = [Match()] # represents "matched" (but we have nothing to show)
             else:
                 result = None
-        logging.debug("search: DomainSearch returning %r" % result)
+        logging.debug("DomainSearch returning %r" % result)
         return result
 
     def xapian_wanted(self):