[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/Transience/Transien death to zLOG

Andreas Jung andreas at andreas-jung.com
Wed May 12 13:02:25 EDT 2004


Log message for revision 24594:
 death to zLOG



-=-
Modified: Zope/trunk/lib/python/Products/Transience/Transience.py
===================================================================
--- Zope/trunk/lib/python/Products/Transience/Transience.py	2004-05-12 16:55:49 UTC (rev 24593)
+++ Zope/trunk/lib/python/Products/Transience/Transience.py	2004-05-12 17:02:25 UTC (rev 24594)
@@ -33,11 +33,11 @@
 from BTrees.OOBTree import OOBTree, OOBucket, OOSet
 from BTrees.IOBTree import IOBTree
 from BTrees.Length import Length
-from zLOG import LOG, WARNING, BLATHER
 import os.path
 import os
 import math, sys, random
 import time
+import logging
 from types import InstanceType
 from TransientObject import TransientObject
 import thread
@@ -48,6 +48,7 @@
 _marker = []
 
 DEBUG = os.environ.get('Z_TOC_DEBUG', '')
+LOG = getLogger('Zope.Transience')
 
 class MaxTransientObjectsExceeded(Exception): pass
 
@@ -69,7 +70,7 @@
     sargs.append(str(time.time()))
     for arg in args:
         sargs.append(str(arg))
-    LOG('Transience', BLATHER, ' '.join(sargs))
+    LOG.debug(' '.join(sargs))
 
 def constructTransientObjectContainer(self, id, title='', timeout_mins=20,
     addNotification=None, delNotification=None, limit=0, REQUEST=None):
@@ -266,11 +267,9 @@
             except (KeyError, AttributeError):
                 path = self.getPhysicalPath()
                 err = 'No such method %s in %s %s'
-                LOG('Transience',
-                    WARNING,
-                    err % (callback, '/'.join(path), name),
-                    error=sys.exc_info()
-                    )
+                LOG.warn(err % (callback, '/'.join(path), name),
+                        exc_info=sys.exc_info()
+                        )
                 return
         else:
             method = callback
@@ -286,22 +285,19 @@
                     except:
                         # dont raise, just log
                         path = self.getPhysicalPath()
-                        LOG('Transience',
-                            WARNING,
+                        LOG.warn( 
                             '%s failed when calling %s in %s' % (name,callback,
                                                             '/'.join(path)),
-                            error=sys.exc_info()
+                            exc_info=sys.exc_info()
                             )
                 finally:
                     setSecurityManager(sm)
             else:
                 err = '%s in %s attempted to call non-callable %s'
                 path = self.getPhysicalPath()
-                LOG('Transience',
-                    WARNING,
-                    err % (name, '/'.join(path), callback),
-                    error=sys.exc_info()
-                    )
+                LOG.warn(err % (name, '/'.join(path), callback),
+                        exc_info=sys.exc_info()
+                        )
 
     security.declareProtected(MANAGE_CONTAINER_PERM,
         'manage_changeTransientObjectContainer')

Modified: Zope/trunk/lib/python/Products/Transience/TransientObject.py
===================================================================
--- Zope/trunk/lib/python/Products/Transience/TransientObject.py	2004-05-12 16:55:49 UTC (rev 24593)
+++ Zope/trunk/lib/python/Products/Transience/TransientObject.py	2004-05-12 17:02:25 UTC (rev 24594)
@@ -26,12 +26,13 @@
      TransientItemContainer
 from AccessControl import ClassSecurityInfo
 import Globals
-from zLOG import LOG, BLATHER, INFO
 import sys
+import logging
 
 _notfound = []
 
 WRITEGRANULARITY=30 # Timing granularity for access write clustering, seconds
+LOG = logging.getLogger('Zope.Transience')
 
 class TransientObject(Persistent, Implicit):
     """ Dictionary-like object that supports additional methods
@@ -192,7 +193,7 @@
         return 1
 
     def _p_resolveConflict(self, saved, state1, state2):
-        LOG('Transience', BLATHER, 'Resolving conflict in TransientObject')
+        LOG.debug('Resolving conflict in TransientObject')
         try:
             states = [saved, state1, state2]
 
@@ -200,7 +201,7 @@
             # because it's a terminal state.
             for state in states:
                 if state.has_key('_invalid'):
-                    LOG('Transience', BLATHER, 'a state was invalid')
+                    LOG.debug('a state was invalid')
                     return state
             # The only other times we can clearly resolve the conflict is if
             # the token, the id, or the creation time don't differ between
@@ -210,7 +211,7 @@
             attrs = ['token', 'id', '_created']
             for attr in attrs:
                 if not (saved.get(attr)==state1.get(attr)==state2.get(attr)):
-                    LOG('Transience', BLATHER, 'cant resolve conflict')
+                    LOG.debug('cant resolve conflict')
                     return None
 
             # Now we need to do real work.
@@ -227,7 +228,7 @@
             # possible.
             states.sort(lastmodified_sort)
             if states[0].get('_last_modified'):
-                LOG('Transience', BLATHER, 'returning last mod state')
+                LOG.debug('returning last mod state')
                 return states[0]
 
             # If we can't determine which object to return on the basis
@@ -236,13 +237,11 @@
             # our parent).  This will return an essentially arbitrary state if
             # all last_accessed values are equal.
             states.sort(lastaccessed_sort)
-            LOG('Transience', BLATHER, 'returning last_accessed state')
+            LOG.debug('returning last_accessed state')
             return states[0]
         except:
-            LOG('Transience', INFO,
-                'Conflict resolution error in TransientObject', '',
-                sys.exc_info()
-                )
+            LOG.info('Conflict resolution error in TransientObject',
+                      exc_info=sys.exc_info())
 
     getName = getId # this is for SQLSession compatibility
 




More information about the Zope-Checkins mailing list