changeset 3127:ea5383222f2f

refactored misc. modules to use own logger instead of request.log
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Wed, 27 Feb 2008 12:46:18 +0100
parents fac1b1e9ea95
children 9213b197d1cb
files MoinMoin/Page.py MoinMoin/caching.py MoinMoin/formatter/text_gedit.py MoinMoin/formatter/text_html.py MoinMoin/parser/text_moin_wiki.py MoinMoin/script/migration/text_moin158_wiki.py MoinMoin/wikiutil.py MoinMoin/xmlrpc/ProcessMail.py MoinMoin/xmlrpc/RemoteScript.py
diffstat 9 files changed, 36 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/Page.py	Wed Feb 27 10:32:52 2008 +0100
+++ b/MoinMoin/Page.py	Wed Feb 27 12:46:18 2008 +0100
@@ -28,7 +28,7 @@
       The mimetype hierarchy should be modelled by a MimeTypeItem class hierarchy.
 
     @copyright: 2000-2004 by Juergen Hermann <jh@web.de>,
-                2005-2007 by MoinMoin:ThomasWaldmann,
+                2005-2008 by MoinMoin:ThomasWaldmann,
                 2006 by MoinMoin:FlorianFesti,
                 2007 by MoinMoin:ReimarBauer
     @license: GNU GPL, see COPYING for details.
@@ -1262,7 +1262,7 @@
                 except Exception, e:
                     if not is_cache_exception(e):
                         raise
-                    request.log('page cache failed after creation')
+                    logging.error('page cache failed after creation')
                     self.format(parser)
 
         request.clock.stop('send_page_content')
@@ -1304,7 +1304,7 @@
             # See http://docs.python.org/lib/module-marshal.html
             raise Exception('CacheNeedsUpdate')
         except Exception, err:
-            request.log('fail to load "%s" cache: %s' %
+            logging.info('failed to load "%s" cache: %s' %
                         (self.page_name, str(err)))
             raise Exception('CacheNeedsUpdate')
 
--- a/MoinMoin/caching.py	Wed Feb 27 10:32:52 2008 +0100
+++ b/MoinMoin/caching.py	Wed Feb 27 12:46:18 2008 +0100
@@ -3,13 +3,16 @@
     MoinMoin caching module
 
     @copyright: 2001-2004 by Juergen Hermann <jh@web.de>,
-                2006-2007 MoinMoin:ThomasWaldmann
+                2006-2008 MoinMoin:ThomasWaldmann
     @license: GNU GPL, see COPYING for details.
 """
 
 import os
 import tempfile
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 from MoinMoin import config
 from MoinMoin.util import filesys, lock, pickle, PICKLE_PROTOCOL
 
@@ -120,7 +123,7 @@
 #                if self.locking:
 #                    self.wlock.release()
 #        else:
-#            self.request.log("Can't acquire write lock in %s" % self.lock_dir)
+#            logging.error("Can't acquire write lock in %s" % self.lock_dir)
 
     def update(self, content):
         try:
@@ -144,7 +147,7 @@
                     if self.locking:
                         self.wlock.release()
             else:
-                self.request.log("Can't acquire write lock in %s" % self.lock_dir)
+                logging.error("Can't acquire write lock in %s" % self.lock_dir)
         except (pickle.PicklingError, OSError, IOError, ValueError), err:
             raise CacheError(str(err))
 
@@ -159,7 +162,7 @@
                 if self.locking:
                     self.wlock.release()
         else:
-            self.request.log("Can't acquire write lock in %s" % self.lock_dir)
+            logging.error("Can't acquire write lock in %s" % self.lock_dir)
 
     def content(self):
         try:
@@ -172,7 +175,7 @@
                     if self.locking:
                         self.rlock.release()
             else:
-                self.request.log("Can't acquire read lock in %s" % self.lock_dir)
+                logging.error("Can't acquire read lock in %s" % self.lock_dir)
             if self.use_pickle:
                 data = pickle.loads(data)
             elif self.use_encode:
--- a/MoinMoin/formatter/text_gedit.py	Wed Feb 27 10:32:52 2008 +0100
+++ b/MoinMoin/formatter/text_gedit.py	Wed Feb 27 12:46:18 2008 +0100
@@ -6,6 +6,9 @@
     @license: GNU GPL, see COPYING for details.
 """
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 from MoinMoin.formatter import FormatterBase, text_html
 from MoinMoin import wikiutil
 from MoinMoin.Page import Page
@@ -164,11 +167,11 @@
         return attrs
 
     def _checkTableAttr(self, attrs, prefix):
-        #self.request.log(repr(attrs))
+        #logging.debug(repr(attrs))
         attrs = text_html.Formatter._checkTableAttr(self, attrs, prefix)
-        #self.request.log(repr(attrs))
+        #logging.debug(repr(attrs))
         attrs = self._style_to_attributes(attrs)
-        #self.request.log(repr(attrs))
+        #logging.debug(repr(attrs))
         return attrs
 
     _allowed_table_attrs = {
--- a/MoinMoin/formatter/text_html.py	Wed Feb 27 10:32:52 2008 +0100
+++ b/MoinMoin/formatter/text_html.py	Wed Feb 27 12:46:18 2008 +0100
@@ -7,6 +7,9 @@
 """
 import os.path, re
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 from MoinMoin.formatter import FormatterBase
 from MoinMoin import wikiutil, i18n
 from MoinMoin.Page import Page
@@ -618,7 +621,7 @@
             querystr['do'] = 'view'
         if on:
             pagename, filename = AttachFile.absoluteName(url, self.page.page_name)
-            #self.request.log("attachment_link: url %s pagename %s filename %s" % (url, pagename, filename))
+            #logging.debug("attachment_link: url %s pagename %s filename %s" % (url, pagename, filename))
             fname = wikiutil.taintfilename(filename)
             if AttachFile.exists(self.request, pagename, fname):
                 target = AttachFile.getAttachUrl(pagename, fname, self.request, do=querystr['do'])
@@ -1288,7 +1291,7 @@
                 pass
         else:
             result['style'] = st
-        #self.request.log("_checkTableAttr returns %r" % result)
+        #logging.debug("_checkTableAttr returns %r" % result)
         return result
 
 
--- a/MoinMoin/parser/text_moin_wiki.py	Wed Feb 27 10:32:52 2008 +0100
+++ b/MoinMoin/parser/text_moin_wiki.py	Wed Feb 27 12:46:18 2008 +0100
@@ -3,7 +3,7 @@
     MoinMoin - MoinMoin Wiki Markup Parser
 
     @copyright: 2000-2002 Juergen Hermann <jh@web.de>,
-                2006-2007 MoinMoin:ThomasWaldmann,
+                2006-2008 MoinMoin:ThomasWaldmann,
                 2007 by MoinMoin:ReimarBauer
     @license: GNU GPL, see COPYING for details.
 """
@@ -1116,7 +1116,7 @@
         attr, msg = wikiutil.parseAttributes(self.request, attrdef, '>', table_extension)
         if msg:
             msg = '<strong class="highlight">%s</strong>' % msg
-        #self.request.log("parseAttributes returned %r" % attr)
+        #logging.debug("parseAttributes returned %r" % attr)
         return attr, msg
 
     def _tableZ_repl(self, word, groups):
--- a/MoinMoin/script/migration/text_moin158_wiki.py	Wed Feb 27 10:32:52 2008 +0100
+++ b/MoinMoin/script/migration/text_moin158_wiki.py	Wed Feb 27 12:46:18 2008 +0100
@@ -697,7 +697,6 @@
         attr, msg = wikiutil.parseAttributes(self.request, attrdef, '>', table_extension)
         if msg:
             msg = '<strong class="highlight">%s</strong>' % msg
-        #self.request.log("parseAttributes returned %r" % attr)
         return attr, msg
 
     def _tableZ_repl(self, word):
--- a/MoinMoin/wikiutil.py	Wed Feb 27 10:32:52 2008 +0100
+++ b/MoinMoin/wikiutil.py	Wed Feb 27 12:46:18 2008 +0100
@@ -5,7 +5,7 @@
     @copyright: 2000-2004 Juergen Hermann <jh@web.de>,
                 2004 by Florian Festi,
                 2006 by Mikko Virkkil,
-                2005-2007 MoinMoin:ThomasWaldmann,
+                2005-2008 MoinMoin:ThomasWaldmann,
                 2007 MoinMoin:ReimarBauer
     @license: GNU GPL, see COPYING for details.
 """
@@ -1794,7 +1794,7 @@
         # call extension function with the current token, the parser, and the dict
         if extension:
             found_flag, msg = extension(key, parser, attrs)
-            #request.log("%r = extension(%r, parser, %r)" % (msg, key, attrs))
+            #logging.debug("%r = extension(%r, parser, %r)" % (msg, key, attrs))
             if found_flag:
                 continue
             elif msg:
@@ -2132,7 +2132,7 @@
             tag = '<a%s href="%s/%s">' % (attrs, request.getScriptname(), params)
             if not on:
                 tag = "%s%s</a>" % (tag, text)
-        request.log("Warning: wikiutil.link_tag called without formatter and without request.html_formatter. tag=%r" % (tag, ))
+        logging.warning("wikiutil.link_tag called without formatter and without request.html_formatter. tag=%r" % (tag, ))
     return tag
 
 def containsConflictMarker(text):
--- a/MoinMoin/xmlrpc/ProcessMail.py	Wed Feb 27 10:32:52 2008 +0100
+++ b/MoinMoin/xmlrpc/ProcessMail.py	Wed Feb 27 12:46:18 2008 +0100
@@ -6,6 +6,9 @@
     @license: GNU GPL, see COPYING for details.
 """
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 from MoinMoin.mail import mailimport
 
 def execute(xmlrpcobj, secret, mail):
@@ -23,6 +26,6 @@
         mailimport.import_mail_from_string(request, mail)
     except mailimport.ProcessingError, e:
         err = u"An error occured while processing the message: " + str(e.args)
-        request.log(err)
+        logging.error(err)
         return xmlrpcobj._outstr(err)
     return xmlrpcobj._outstr(u"OK")
--- a/MoinMoin/xmlrpc/RemoteScript.py	Wed Feb 27 10:32:52 2008 +0100
+++ b/MoinMoin/xmlrpc/RemoteScript.py	Wed Feb 27 12:46:18 2008 +0100
@@ -6,6 +6,9 @@
     @license: GNU GPL, see COPYING for details.
 """
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 from MoinMoin.script import MoinScript
 
 def execute(xmlrpcobj, their_secret, argv):
@@ -20,11 +23,11 @@
         return u"Invalid password"
 
     try:
-        request.log("RemoteScript argv: %r" % argv)
+        logging.info("RemoteScript argv: %r" % argv)
         MoinScript(argv).run(showtime=0)
     except Exception, err:
         e = str(err)
-        request.log(e)
+        logging.error(e)
         return xmlrpcobj._outstr(e)
     return xmlrpcobj._outstr(u"OK")