[Zope3-checkins] CVS: Zope3/lib/python/Zope/Server - ServerBase.py:1.3

Guido van Rossum guido@python.org
Thu, 19 Dec 2002 20:57:12 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/Server
In directory cvs.zope.org:/tmp/cvs-serv6792

Modified Files:
	ServerBase.py 
Log Message:
Redefine log() and log_info() to use the logging module.


=== Zope3/lib/python/Zope/Server/ServerBase.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/Server/ServerBase.py:1.2	Mon Jun 10 19:29:34 2002
+++ Zope3/lib/python/Zope/Server/ServerBase.py	Thu Dec 19 20:57:11 2002
@@ -17,6 +17,7 @@
 """
 
 import asyncore
+import logging
 import socket
 
 from Adjustments import default_adj
@@ -47,9 +48,23 @@
         self.verbose = verbose
         self.hit_log = hit_log
         self.server_name = self.computeServerName(ip)
+        self.logger = logging.getLogger(self.__class__.__name__)
 
         if start:
             self.accept_connections()
+
+    def log(self, message):
+        # Override asyncore's default log()
+        self.logger.info(message)
+
+    level_mapping = {
+        'info': logging.INFO,
+        'error': logging.ERROR,
+        'warning': logging.WARN,
+        }
+
+    def log_info(self, message, type='info'):
+        self.logger.log(self.level_mapping.get(type, logging.INFO), message)
 
     def computeServerName(self, ip=''):
         if ip: