[Zope-Checkins] SVN: Zope/branches/2.9/ Added a 'conflict-error-log-level' directive to zope.conf, to set the

Florent Guillaume fg at nuxeo.com
Sun Dec 18 14:01:42 EST 2005


Log message for revision 40864:
  Added a 'conflict-error-log-level' directive to zope.conf, to set the
  level at which conflict errors (which are normally retried
  automatically) are logged. The default is 'info'.
  
  This doesn't interfere with the error_log site object which copies
  non-retried conflict errors the the error log at level 'error'.
  

Changed:
  U   Zope/branches/2.9/doc/CHANGES.txt
  U   Zope/branches/2.9/lib/python/Zope2/App/startup.py
  U   Zope/branches/2.9/lib/python/Zope2/Startup/zopeschema.xml
  U   Zope/branches/2.9/skel/etc/zope.conf.in

-=-
Modified: Zope/branches/2.9/doc/CHANGES.txt
===================================================================
--- Zope/branches/2.9/doc/CHANGES.txt	2005-12-18 14:23:26 UTC (rev 40863)
+++ Zope/branches/2.9/doc/CHANGES.txt	2005-12-18 19:01:42 UTC (rev 40864)
@@ -44,6 +44,10 @@
 
      - The SiteErrorLog now copies exceptions to the event log by default.
 
+     - Added a 'conflict-error-log-level' directive to zope.conf, to set
+       the level at which conflict errors (which are normally retried
+       automatically) are logged. The default is 'info'.
+
   Zope 2.9.0 beta 1 (2005/12/06)
 
     Features added

Modified: Zope/branches/2.9/lib/python/Zope2/App/startup.py
===================================================================
--- Zope/branches/2.9/lib/python/Zope2/App/startup.py	2005-12-18 14:23:26 UTC (rev 40863)
+++ Zope/branches/2.9/lib/python/Zope2/App/startup.py	2005-12-18 19:01:42 UTC (rev 40864)
@@ -136,7 +136,7 @@
 conflict_errors = 0
 unresolved_conflict_errors = 0
 
-conflict_logger = logging.getLogger('ZODB.Conflict')
+conflict_logger = logging.getLogger('ZPublisher.Conflict')
 
 def zpublisher_exception_hook(published, REQUEST, t, v, traceback):
     global unresolved_conflict_errors
@@ -149,19 +149,18 @@
             if t is SystemExit:
                 raise
             if issubclass(t, ConflictError):
-                conflict_errors = conflict_errors + 1
-                # This logs _all_ conflict errors
-                conflict_logger.info(
-                    '%s at %s (%i conflicts, of which %i'
-                    ' were unresolved, since startup at %s)',
-                    v,
-                    REQUEST.get('PATH_INFO', '<unknown>'),
-                    conflict_errors,
-                    unresolved_conflict_errors,
-                    startup_time
-                    )
-                # This debug logging really doesn't help a lot...
-                conflict_logger.debug('Conflict traceback',exc_info=True)
+                conflict_errors += 1
+                level = getConfiguration().conflict_error_log_level
+                if level:
+                    conflict_logger.log(level,
+                        "%s at %s: %s (%d conflicts (%d unresolved) "
+                        "since startup at %s)",
+                        v.__class__.__name__,
+                        REQUEST.get('PATH_INFO', '<unknown>'),
+                        v,
+                        conflict_errors,
+                        unresolved_conflict_errors,
+                        startup_time)
                 raise ZPublisher.Retry(t, v, traceback)
             if t is ZPublisher.Retry:
                 try:

Modified: Zope/branches/2.9/lib/python/Zope2/Startup/zopeschema.xml
===================================================================
--- Zope/branches/2.9/lib/python/Zope2/Startup/zopeschema.xml	2005-12-18 14:23:26 UTC (rev 40863)
+++ Zope/branches/2.9/lib/python/Zope2/Startup/zopeschema.xml	2005-12-18 19:01:42 UTC (rev 40864)
@@ -760,6 +760,20 @@
     </description>
   </section>
 
+  <key name="conflict-error-log-level"
+       datatype="ZConfig.components.logger.datatypes.logging_level"
+       default="info">
+     <description>
+       Specifies at which level conflict errors are logged. Conflict
+       errors, when occuring in small numbers, are a normal part of the
+       Zope optimistic transaction conflict resolution algorithms. They
+       are retried automatically a few times, and are therefore usually
+       not visible by the user. You can specify 'notset' if you don't
+       want them logged, or use any other logger level.
+     </description>
+     <metadefault>info</metadefault>
+  </key>
+
   <!-- max-listen-sockets and large-file-threshold should really go
        into the ZServer package, but I can't quite figure out how to
        put it there -->

Modified: Zope/branches/2.9/skel/etc/zope.conf.in
===================================================================
--- Zope/branches/2.9/skel/etc/zope.conf.in	2005-12-18 14:23:26 UTC (rev 40863)
+++ Zope/branches/2.9/skel/etc/zope.conf.in	2005-12-18 19:01:42 UTC (rev 40864)
@@ -759,6 +759,24 @@
 #   </logfile>
 # </logger>
 
+
+# Directive: conflict-error-log-level
+#
+# Description:
+#     Specifies at which level conflict errors are logged. Conflict
+#     errors, when occuring in small numbers, are a normal part of the
+#     Zope optimistic transaction conflict resolution algorithms. They
+#     are retried automatically a few times, and are therefore usually
+#     not visible by the user. You can specify 'notset' if you don't
+#     want them logged, or use any other logger level (see above).
+#
+# Default: info
+#
+# Example:
+#
+#    conflict-error-log-level blather
+
+
 # Directive: warnfilter
 #
 # Description:



More information about the Zope-Checkins mailing list