changeset 3611:0b220c040be4

replace request.log by direct logging calls
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 17 May 2008 22:11:05 +0200
parents 39456a5dc4e8
children 6f06c7d051a4 2232946adeb3
files MoinMoin/filter/application_vnd_oasis_opendocument.py MoinMoin/filter/application_vnd_sun_xml.py MoinMoin/filter/text_xml.py MoinMoin/request/__init__.py
diffstat 4 files changed, 27 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/filter/application_vnd_oasis_opendocument.py	Sat May 17 21:23:09 2008 +0200
+++ b/MoinMoin/filter/application_vnd_oasis_opendocument.py	Sat May 17 22:11:05 2008 +0200
@@ -10,6 +10,9 @@
 
 import re, zipfile
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 rx_stripxml = re.compile("<[^>]*?>", re.DOTALL|re.MULTILINE)
 
 def execute(indexobj, filename):
@@ -19,7 +22,7 @@
         zf.close()
         data = " ".join(rx_stripxml.sub(" ", data).split())
     except RuntimeError, err:
-        indexobj.request.log(str(err))
+        logging.error(str(err))
         data = ""
     return data.decode('utf-8')
 
--- a/MoinMoin/filter/application_vnd_sun_xml.py	Sat May 17 21:23:09 2008 +0200
+++ b/MoinMoin/filter/application_vnd_sun_xml.py	Sat May 17 22:11:05 2008 +0200
@@ -10,6 +10,9 @@
 
 import re, zipfile
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 rx_stripxml = re.compile("<[^>]*?>", re.DOTALL|re.MULTILINE)
 
 def execute(indexobj, filename):
@@ -19,7 +22,7 @@
         zf.close()
         data = " ".join(rx_stripxml.sub(" ", data).split())
     except RuntimeError, err:
-        indexobj.request.log(str(err))
+        logging.error(str(err))
         data = ""
     return data.decode('utf-8')
 
--- a/MoinMoin/filter/text_xml.py	Sat May 17 21:23:09 2008 +0200
+++ b/MoinMoin/filter/text_xml.py	Sat May 17 22:11:05 2008 +0200
@@ -7,6 +7,10 @@
 """
 
 import re
+
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 from MoinMoin.filter.text import execute as textfilter
 
 rx_stripxml = re.compile("<[^>]*?>", re.DOTALL|re.MULTILINE)
@@ -16,7 +20,7 @@
     try:
         data = " ".join(rx_stripxml.sub(" ", data).split())
     except RuntimeError, err:
-        indexobj.request.log(str(err))
+        logging.error(str(err))
         data = ""
     return data
 
--- a/MoinMoin/request/__init__.py	Sat May 17 21:23:09 2008 +0200
+++ b/MoinMoin/request/__init__.py	Sat May 17 22:11:05 2008 +0200
@@ -848,7 +848,9 @@
             self.write = self.writestack.pop()
 
     def log(self, msg):
-        """ Log msg to logging framework """
+        """ DEPRECATED - Log msg to logging framework
+            Please call logging.info(...) directly!
+        """
         msg = msg.strip()
         # Encode unicode msg
         if isinstance(msg, unicode):
@@ -881,7 +883,7 @@
 
         pid = os.getpid()
         msg = 'Timing %5d %-6s %4s %-10s %s\n' % (pid, total, indicator, action, self.url)
-        self.log(msg)
+        logging.info(msg)
 
     def send_file(self, fileobj, bufsize=8192, do_flush=False):
         """ Send a file to the output stream.
@@ -916,7 +918,7 @@
                     continue
                 wd.append(d)
             except UnicodeError:
-                self.log("Unicode error on: %s" % repr(d))
+                logging.error("Unicode error on: %s" % repr(d))
         return ''.join(wd)
 
     def decodePagename(self, name):
@@ -1035,11 +1037,11 @@
             for host in self.cfg.hosts_deny:
                 if host[-1] == '.' and ip.startswith(host):
                     forbidden = 1
-                    #self.log("hosts_deny (net): %s" % str(forbidden))
+                    logging.debug("hosts_deny (net): %s" % str(forbidden))
                     break
                 if ip == host:
                     forbidden = 1
-                    #self.log("hosts_deny (ip): %s" % str(forbidden))
+                    logging.debug("hosts_deny (ip): %s" % str(forbidden))
                     break
         return forbidden
 
@@ -1346,9 +1348,9 @@
 
         if self.sent_headers:
             # Send headers only once
-            self.log("Attempt to send headers twice!\n")
-            self.log("First attempt:\n%s" % self.sent_headers)
-            self.log("Second attempt:\n%s" % tracehere)
+            logging.error("Attempt to send headers twice!")
+            logging.error("First attempt:\n%s" % self.sent_headers)
+            logging.error("Second attempt:\n%s" % tracehere)
             raise HeadersAlreadySentException("emit_http_headers has already been called before!")
         else:
             self.sent_headers = tracehere
@@ -1369,9 +1371,9 @@
                     headers[lkey] = headers[lkey][0], '%s, %s' % (headers[lkey][1], value)
                     traces[lkey] = trace
                 else:
-                    self.log("Duplicate http header: %r (ignored)" % header)
-                    self.log("Header added first at:\n%s" % traces[lkey])
-                    self.log("Header added again at:\n%s" % trace)
+                    logging.warning("Duplicate http header: %r (ignored)" % header)
+                    logging.warning("Header added first at:\n%s" % traces[lkey])
+                    logging.warning("Header added again at:\n%s" % trace)
             else:
                 headers[lkey] = (key, value)
                 traces[lkey] = trace
@@ -1387,7 +1389,7 @@
                 status = headers['status'][1]
                 int(status.split(' ', 1)[0])
             except:
-                self.log("emit_http_headers called with invalid header Status: %r" % status)
+                logging.error("emit_http_headers called with invalid header Status: %r" % status)
                 headers['status'] = ('Status', '500 Server Error - invalid status header')
 
         header_format = '%s: %s'