[Zope-Checkins] SVN: Zope/branches/2.9/ Improved logging of ConflictErrors. Now a log is made at level BLATHER

Florent Guillaume fg at nuxeo.com
Thu Dec 1 13:39:13 EST 2005


Log message for revision 40454:
  Improved logging of ConflictErrors. Now a log is made at level BLATHER
  with traceback for any conflict retried. In addition, a log is made at
  level ERROR for a conflict that can't be retried anymore and is returned
  to the browser as an error. Nothing is logged anymore at level INFO.
  

Changed:
  U   Zope/branches/2.9/doc/CHANGES.txt
  U   Zope/branches/2.9/lib/python/Zope2/App/startup.py

-=-
Modified: Zope/branches/2.9/doc/CHANGES.txt
===================================================================
--- Zope/branches/2.9/doc/CHANGES.txt	2005-12-01 18:29:26 UTC (rev 40453)
+++ Zope/branches/2.9/doc/CHANGES.txt	2005-12-01 18:39:12 UTC (rev 40454)
@@ -24,8 +24,14 @@
 
   Trunk only (unreleased)
 
-    Features added  
+    Features added
 
+      - Improved logging of ConflictErrors. Now a log is made at level
+        BLATHER with traceback for any conflict retried. In addition, a
+        log is made at level ERROR for a conflict that can't be retried
+        anymore and is returned to the browser as an error. Nothing is
+        logged anymore at level INFO.
+
       - Fixed unclear security declarations. Warn when an attempt is
         made to have a security declaration on a nonexistent method.
 

Modified: Zope/branches/2.9/lib/python/Zope2/App/startup.py
===================================================================
--- Zope/branches/2.9/lib/python/Zope2/App/startup.py	2005-12-01 18:29:26 UTC (rev 40453)
+++ Zope/branches/2.9/lib/python/Zope2/App/startup.py	2005-12-01 18:39:12 UTC (rev 40454)
@@ -20,7 +20,7 @@
 from App.config import getConfiguration
 from types import StringType, ListType
 from zExceptions import Unauthorized
-from zLOG import LOG, WARNING, INFO, BLATHER, log_time
+from zLOG import LOG, ERROR, WARNING, INFO, BLATHER, log_time
 from ZODB.POSException import ConflictError
 import transaction
 import AccessControl.User
@@ -142,20 +142,25 @@
             if t is SystemExit:
                 raise
             if issubclass(t, ConflictError):
-                # First, we need to close the current connection. We'll
-                # do this by releasing the hold on it. There should be
-                # some sane protocol for this, but for now we'll use
-                # brute force:
                 global conflict_errors
                 conflict_errors = conflict_errors + 1
                 method_name = REQUEST.get('PATH_INFO', '')
-                err = ('ZODB conflict error at %s '
-                       '(%s conflicts since startup at %s)')
-                LOG(err % (method_name, conflict_errors, startup_time),
-                    INFO, '')
-                LOG('Conflict traceback', BLATHER, '', error=sys.exc_info())
+                LOG('ZODB', BLATHER, "%s at %s: %s"
+                    " (%s conflicts since startup at %s)"
+                    % (v.__class__.__name__, method_name, v,
+                       conflict_errors, startup_time),
+                    error=(t, v, traceback))
                 raise ZPublisher.Retry(t, v, traceback)
-            if t is ZPublisher.Retry: v.reraise()
+            if t is ZPublisher.Retry:
+                # An exception that can't be retried anymore
+                # Retrieve the original exception
+                try: v.reraise()
+                except: t, v, traceback = sys.exc_info()
+                # Log it as ERROR
+                method_name = REQUEST.get('PATH_INFO', '')
+                LOG('Publisher', ERROR, "Unhandled %s at %s: %s"
+                    % (v.__class__.__name__, method_name, v))
+                # Then fall through to display the error to the user
 
         try:
             log = aq_acquire(published, '__error_log__', containment=1)



More information about the Zope-Checkins mailing list