[Zodb-checkins] CVS: ZEO/ZEO - StorageServer.py:1.49

Jeremy Hylton jeremy@zope.com
Thu, 29 Aug 2002 17:07:52 -0400


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

Modified Files:
	StorageServer.py 
Log Message:
Merge slog() function and self._log() method.


=== ZEO/ZEO/StorageServer.py 1.48 => 1.49 ===
--- ZEO/ZEO/StorageServer.py:1.48	Thu Aug 29 16:59:03 2002
+++ ZEO/ZEO/StorageServer.py	Thu Aug 29 17:07:52 2002
@@ -49,13 +49,6 @@
         error=None):
     zLOG.LOG(label, level, message, error=error)
 
-# a version of log that includes the storage name
-def slog(storage, msg, level=zLOG.INFO, error=None, pid=os.getpid()):
-    name = getattr(storage, '__name__', None)
-    if name is None:
-        name = str(storage)
-    zLOG.LOG("ZEO Server:%s:%s" % (pid, name), level, msg, error=error)
-
 class StorageServerError(StorageError):
     pass
 
@@ -126,6 +119,7 @@
     def close(self):
         # When this storage closes, we must ensure that it aborts
         # any pending transaction.  Not sure if this is the clearest way.
+        zLOG.LOG
         if self._transaction is not None:
             self.tpc_abort(self._transaction.id)
         self._conn.close()
@@ -145,8 +139,10 @@
         return "<%s %X trans=%s s_trans=%s>" % (name, id(self), tid, stid)
 
     def _log(self, msg, level=zLOG.INFO, error=None, pid=os.getpid()):
-        zLOG.LOG("ZEO Server:%s:%s" % (pid, self.__storage_id),
-                   level, msg, error=error)
+        name = getattr(self, '__name__', None)
+        if name is None:
+            name = str(self)
+        zLOG.LOG("ZEO Server:%s:%s" % (pid, name), level, msg, error=error)
 
     def setup_delegation(self):
         """Delegate several methods to the storage"""
@@ -162,16 +158,14 @@
     def _check_tid(self, tid, exc=None):
         caller = sys._getframe().f_back.f_code.co_name
         if self._transaction is None:
-            self._log("no current transaction: %s()" % caller,
-                zLOG.PROBLEM)
+            self._log("no current transaction: %s()" % caller, zLOG.PROBLEM)
             if exc is not None:
                 raise exc(None, tid)
             else:
                 return 0
         if self._transaction.id != tid:
             self._log("%s(%s) invalid; current transaction = %s" % \
-                (caller, repr(tid), repr(self._transaction.id)),
-                zLOG.PROBLEM)
+                 (caller, repr(tid), repr(self._transaction.id)), zLOG.PROBLEM)
             if exc is not None:
                 raise exc(self._transaction.id, tid)
             else:
@@ -487,8 +481,8 @@
         except Exception:
             # Unexpected storage errors are logged and passed to the client
             exc_info = sys.exc_info()
-            slog(self.storage, "store error: %s, %s" % exc_info[:2],
-                zLOG.ERROR, error=exc_info)
+            self.storage._log("store error: %s, %s" % exc_info[:2],
+                              zLOG.ERROR, error=exc_info)
             newserial = exc_info[1]
             del exc_info
         else:
@@ -499,7 +493,7 @@
             dump(newserial, 1)
         except:
             msg = "Couldn't pickle storage exception: %s" % repr(newserial)
-            slog(self.storage, msg, zLOG.ERROR)
+            self.storage._log(msg, zLOG.ERROR)
             dump('', 1) # clear pickler
             r = StorageServerError(msg)
             newserial = r