[Zope3-checkins] CVS: Zope3/lib/python/ZEO - ClientStorage.py:1.47

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


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

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


=== Zope3/lib/python/ZEO/ClientStorage.py 1.46 => 1.47 ===
--- Zope3/lib/python/ZEO/ClientStorage.py:1.46	Fri Dec 13 17:05:01 2002
+++ Zope3/lib/python/ZEO/ClientStorage.py	Thu Dec 19 16:20:16 2002
@@ -33,6 +33,7 @@
 import threading
 import time
 import types
+import logging
 
 from ZEO import ClientCache, ServerStub
 from ZEO.TransactionBuffer import TransactionBuffer
@@ -41,10 +42,6 @@
 
 from ZODB import POSException
 from ZODB.TimeStamp import TimeStamp
-from zLOG import LOG, PROBLEM, INFO, BLATHER
-
-def log2(type, msg, subsys="ZCS:%d" % os.getpid()):
-    LOG(subsys, type, msg)
 
 try:
     from ZODB.ConflictResolution import ResolvedSerial
@@ -175,27 +172,30 @@
             true.
         """
 
-        log2(INFO, "%s (pid=%d) created %s/%s for storage: %r" %
-             (self.__class__.__name__,
-              os.getpid(),
-              read_only and "RO" or "RW",
-              read_only_fallback and "fallback" or "normal",
-              storage))
+        self.logger = logging.getLogger("ZCS:%d" % os.getpid())
+
+        self.logger.warn("%s (pid=%d) created %s/%s for storage: %r",
+                         self.__class__.__name__,
+                         os.getpid(),
+                         read_only and "RO" or "RW",
+                         read_only_fallback and "fallback" or "normal",
+                         storage)
 
         if debug:
-            log2(INFO, "ClientStorage(): debug argument is no longer used")
+            self.logger.warn(
+                "ClientStorage(): debug argument is no longer used")
 
         # wait defaults to True, but wait_for_server_on_startup overrides
         # if not None
         if wait_for_server_on_startup is not None:
             if wait is not None and wait != wait_for_server_on_startup:
-                log2(PROBLEM,
-                     "ClientStorage(): conflicting values for wait and "
-                     "wait_for_server_on_startup; wait prevails")
+                self.logger.error(
+                    "ClientStorage(): conflicting values for wait and "
+                    "wait_for_server_on_startup; wait prevails")
             else:
-                log2(INFO,
-                     "ClientStorage(): wait_for_server_on_startup "
-                     "is deprecated; please use wait instead")
+                self.logger.warn(
+                    "ClientStorage(): wait_for_server_on_startup "
+                    "is deprecated; please use wait instead")
                 wait = wait_for_server_on_startup
         elif wait is None:
             wait = 1
@@ -320,7 +320,7 @@
         succeeding register() call is deemed an optimal match, and any
         exception raised by register() is passed through.
         """
-        log2(INFO, "Testing connection %r" % conn)
+        self.logger.warn("Testing connection %r", conn)
         # XXX Check the protocol version here?
         stub = self.StorageServerStubClass(conn)
         try:
@@ -329,7 +329,8 @@
         except POSException.ReadOnlyError:
             if not self._read_only_fallback:
                 raise
-            log2(INFO, "Got ReadOnlyError; trying again with read_only=1")
+            self.logger.warn(
+                "Got ReadOnlyError; trying again with read_only=1")
             stub.register(str(self._storage), read_only=1)
             return 0
 
@@ -340,9 +341,9 @@
         connection should be used.
         """
         if self._connection is not None:
-            log2(INFO, "Reconnected to storage")
+            self.logger.warn("Reconnected to storage")
         else:
-            log2(INFO, "Connected to storage")
+            self.logger.warn("Connected to storage")
         self.set_server_addr(conn.get_addr())
         stub = self.StorageServerStubClass(conn)
         self._oids = []
@@ -370,7 +371,7 @@
             try:
                 canonical, aliases, addrs = socket.gethostbyaddr(host)
             except socket.error, err:
-                log2(BLATHER, "Error resoving host: %s (%s)" % (host, err))
+                self.logger.info("Error resoving host: %s (%s)", host, err)
                 canonical = host
             self._server_addr = str((canonical, addr[1]))
 
@@ -404,7 +405,7 @@
         This is called by ConnectionManager when the connection is
         closed or when certain problems with the connection occur.
         """
-        log2(PROBLEM, "Disconnected from storage")
+        self.logger.error("Disconnected from storage")
         self._connection = None
         self._server = disconnected_stub
 
@@ -818,10 +819,8 @@
             try:
                 self._db.invalidate(oid, version=version)
             except AttributeError, msg:
-                log2(PROBLEM,
-                    "Invalidate(%s, %s) failed for _db: %s" % (repr(oid),
-                                                               repr(version),
-                                                               msg))
+                self.logger.error("Invalidate(%r, %r) failed for _db: %s",
+                                  oid, version, msg)
 
     # Unfortunately, the ZEO 2 wire protocol uses different names for
     # several of the callback methods invoked by the StorageServer.