[Checkins] SVN: transaction/branches/sphinx/ Allow hooking logger for testing.
Tres Seaver
cvs-admin at zope.org
Mon Dec 17 22:09:06 UTC 2012
Log message for revision 128717:
Allow hooking logger for testing.
Changed:
_U transaction/branches/sphinx/
U transaction/branches/sphinx/transaction/_transaction.py
-=-
Modified: transaction/branches/sphinx/transaction/_transaction.py
===================================================================
--- transaction/branches/sphinx/transaction/_transaction.py 2012-12-17 22:09:04 UTC (rev 128716)
+++ transaction/branches/sphinx/transaction/_transaction.py 2012-12-17 22:09:05 UTC (rev 128717)
@@ -116,12 +116,19 @@
_marker = object()
-_TB_BUFFER = None
-def _makeTracebackBuffer(): #unittests may hook
+_TB_BUFFER = None #unittests may hook
+def _makeTracebackBuffer():
if _TB_BUFFER is not None:
return _TB_BUFFER
return StringIO()
+_LOGGER = None #unittests may hook
+def _makeLogger():
+ if _LOGGER is not None:
+ return _LOGGER
+ return logging.getLogger("txn.%d" % get_thread_ident())
+
+
# The point of this is to avoid hiding exceptions (which the builtin
# hasattr() does).
def myhasattr(obj, attr):
@@ -183,7 +190,7 @@
# directly by storages, leading underscore notwithstanding.
self._extension = {}
- self.log = logging.getLogger("txn.%d" % get_thread_ident())
+ self.log = _makeLogger()
self.log.debug("new transaction")
# If a commit fails, the traceback is saved in _failure_traceback.
More information about the checkins
mailing list