[Zope3-checkins] CVS: Zope3/lib/python/ZEO/tests - zeoserver.py:1.5

Guido van Rossum guido@python.org
Thu, 19 Dec 2002 16:46:36 -0500


Update of /cvs-repository/Zope3/lib/python/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv5224

Modified Files:
	zeoserver.py 
Log Message:
Convert to logging module.

The ZEO package is now free of referernces to zLOG!  Only 42 more
files to go.


=== Zope3/lib/python/ZEO/tests/zeoserver.py 1.4 => 1.5 ===
--- Zope3/lib/python/ZEO/tests/zeoserver.py:1.4	Thu Dec 19 15:50:20 2002
+++ Zope3/lib/python/ZEO/tests/zeoserver.py	Thu Dec 19 16:46:36 2002
@@ -24,7 +24,6 @@
 import ThreadedAsync.LoopCallback
 
 import ZConfig
-import zLOG
 from ZODB import StorageConfig
 import ZEO.StorageServer
 
@@ -45,10 +44,6 @@
         pass
 
 
-def log(label, msg, *args):
-    zLOG.LOG(label, zLOG.DEBUG, msg % args)
-
-
 class ZEOTestServer(asyncore.dispatcher):
     """A server for killing the whole process at the end of a test.
 
@@ -72,8 +67,9 @@
         self._keep = keep
         # Count down to zero, the number of connects
         self._count = 1
-        # For zLOG
-        self._label ='zeoserver:%d @ %s' % (os.getpid(), addr)
+        # Create a logger
+        self.logger = logging.getLogger('zeoserver.%d.%s' %
+                                        (os.getpid(), addr))
         self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
         # Some ZEO tests attempt a quick start of the server using the same
         # port so we have to set the reuse flag.
@@ -86,24 +82,21 @@
             traceback.print_exc()
             raise
         self.listen(5)
-        self.log('bound and listening')
-
-    def log(self, msg, *args):
-        log(self._label, msg, *args)
+        self.logger.info('bound and listening')
 
     def handle_accept(self):
         sock, addr = self.accept()
-        self.log('in handle_accept()')
+        self.logger.info('in handle_accept()')
         # When we're done with everything, close the storage.  Do not write
         # the ack character until the storage is finished closing.
         if self._count <= 0:
-            self.log('closing the storage')
+            self.logger.info('closing the storage')
             self._storage.close()
             if not self._keep:
                 cleanup(self._storage)
-            self.log('exiting')
+            self.logger.info('exiting')
             os._exit(0)
-        self.log('continuing')
+        self.logger.info('continuing')
         sock.send('X')
         self._count -= 1
 
@@ -118,8 +111,10 @@
     if os.path.exists("log.ini"):
         logging.config.fileConfig("log.ini")
 
-    label = 'zeoserver:%d' % os.getpid()
-    log(label, 'starting')
+    # Create a logger
+    logger = logging.getLogger('zeoserver.%d' % os.getpid())
+    logger.info('starting')
+
     # We don't do much sanity checking of the arguments, since if we get it
     # wrong, it's a bug in the test suite.
     ro_svr = False
@@ -144,18 +139,19 @@
     zeo_port = int(args[0])
     test_port = zeo_port + 1
     try:
-        log(label, 'creating the test server, ro: %s, keep: %s', ro_svr, keep)
+        logger.info('creating the test server, ro: %s, keep: %s',
+                    ro_svr, keep)
         t = ZEOTestServer(('', test_port), storage, keep)
     except socket.error, e:
         if e[0] <> errno.EADDRINUSE: raise
-        log(label, 'addr in use, closing and exiting')
+        logger.info('addr in use, closing and exiting')
         storage.close()
         cleanup(storage)
         sys.exit(2)
     addr = ('', zeo_port)
-    log(label, 'creating the storage server')
+    logger.info('creating the storage server')
     serv = ZEO.StorageServer.StorageServer(addr, {'1': storage}, ro_svr)
-    log(label, 'entering ThreadedAsync loop')
+    logger.info('entering ThreadedAsync loop')
     ThreadedAsync.LoopCallback.loop()