Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Commit

Permalink
Added transaction ID to LoggingDecorator
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Groszer committed Mar 30, 2012
1 parent 6e9a2c5 commit 7869eda
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -5,6 +5,8 @@ CHANGES
0.7.0 (2012-03-??)
------------------

- Added transaction ID to LoggingDecorator

- Feature: A new ``IConflictHandler`` interface now controls all aspects of
conflict resolution. The following implementations are provided:

Expand Down
9 changes: 6 additions & 3 deletions src/mongopersist/datamanager.py
Expand Up @@ -91,12 +91,15 @@ def __call__(self, *args, **kwargs):
tb = ''.join(exceptionformatter.extract_stack(
sys.exc_info()[2].tb_frame.f_back, limit=self.TB_LIMIT))
else:
tb = '<omitted>'
tb = ' <omitted>'

txn = transaction.get()
txn = '%i - %s' %(id(txn), txn.description),

COLLECTION_LOG.debug(
"collection: %s.%s %s,\n args:%r,\n kwargs:%r, \n tb:\n%s",
"collection: %s.%s %s,\n TXN:%s,\n args:%r,\n kwargs:%r, \n tb:\n%s",
self.collection.database.name, self.collection.name,
self.function.__name__, args, kwargs, tb)
self.function.__name__, txn, args, kwargs, tb)

return self.function(*args, **kwargs)

Expand Down
5 changes: 4 additions & 1 deletion src/mongopersist/tests/test_datamanager.py
Expand Up @@ -859,6 +859,7 @@ def doctest_LoggingDecorator_basic():
>>> logging_find = datamanager.LoggingDecorator(coll, coll.find)
>>> list(logging_find({'life': 42}))
collection: mongopersist_test.mongopersist.tests.test_datamanager.Foo find,
TXN:('... - ',),
args:({'life': 42},),
kwargs:{},
tb:
Expand All @@ -871,6 +872,7 @@ def doctest_LoggingDecorator_basic():
>>> list(logging_find(spec={'life': 42}))
collection: mongopersist_test.mongopersist.tests.test_datamanager.Foo find,
TXN:('... - ',),
args:(),
kwargs:{'spec': {'life': 42}},
tb:
Expand All @@ -884,10 +886,11 @@ def doctest_LoggingDecorator_basic():
>>> logging_find.ADD_TB = False
>>> list(logging_find({'life': 42}))
collection: mongopersist_test.mongopersist.tests.test_datamanager.Foo find,
TXN:('... - ',),
args:({'life': 42},),
kwargs:{},
tb:
<omitted>
<omitted>
[]
"""

Expand Down

0 comments on commit 7869eda

Please sign in to comment.