[Zodb-checkins] CVS: ZODB3/ZEO - ClientStorage.py:1.73.2.7

Jeremy Hylton jeremy@zope.com
Mon, 9 Dec 2002 15:52:27 -0500


Update of /cvs-repository/ZODB3/ZEO
In directory cvs.zope.org:/tmp/cvs-serv16466/ZEO

Modified Files:
      Tag: ZODB3-3_1-branch
	ClientStorage.py 
Log Message:
Improved connection logging.

When connecting or disconnecting, include the server address in the
log message.

When reconnecting (i.e. replacing a read-only fallback with a
read-write connection), make sure the disconnect is logged before the
reconnect.



=== ZODB3/ZEO/ClientStorage.py 1.73.2.6 => 1.73.2.7 ===
--- ZODB3/ZEO/ClientStorage.py:1.73.2.6	Fri Nov 15 12:18:56 2002
+++ ZODB3/ZEO/ClientStorage.py	Mon Dec  9 15:52:26 2002
@@ -339,11 +339,13 @@
         This is called by ConnectionManager after it has decided which
         connection should be used.
         """
+        # XXX would like to report whether we get a read-only connection
         if self._connection is not None:
-            log2(INFO, "Reconnected to storage")
+            reconnect = 1
         else:
-            log2(INFO, "Connected to storage")
-        self.set_server_addr(conn.get_addr())
+            reconnect = 0
+        addr = conn.get_addr()
+        self.set_server_addr(addr)
         stub = self.StorageServerStubClass(conn)
         self._oids = []
         self._info.update(stub.get_info())
@@ -355,6 +357,11 @@
         self._connection = conn
         self._server = stub
 
+        if reconnect:
+            log2(INFO, "Reconnected to storage: %s" % repr(addr))
+        else:
+            log2(INFO, "Connected to storage: %s" % repr(addr))
+
     def set_server_addr(self, addr):
         # Normalize server address and convert to string
         if isinstance(addr, types.StringType):
@@ -404,7 +411,8 @@
         This is called by ConnectionManager when the connection is
         closed or when certain problems with the connection occur.
         """
-        log2(PROBLEM, "Disconnected from storage")
+        log2(PROBLEM, "Disconnected from storage: %s"
+             % repr(self._server_addr))
         self._connection = None
         self._server = disconnected_stub