Add message parameter to PDB.savepoint for better logging.

Helps to have a visual on which methods are creating the saves.
This commit is contained in:
voussoir 2018-07-29 16:03:04 -07:00
parent 56e7472c93
commit 9328600355
2 changed files with 6 additions and 3 deletions

View file

@ -78,7 +78,7 @@ def transaction(method):
@functools.wraps(method)
def wrapped_transaction(self, *args, **kwargs):
photodb = _get_relevant_photodb(self)
savepoint_id = photodb.savepoint()
savepoint_id = photodb.savepoint(message=method.__qualname__)
try:
result = method(self, *args, **kwargs)
except Exception as e:

View file

@ -720,8 +720,11 @@ class PDBSQLMixin:
if item == restore_to:
break
def savepoint(self):
def savepoint(self, message=None):
savepoint_id = helpers.random_hex(length=16)
if message:
self.log.debug('Savepoint %s for %s.', savepoint_id, message)
else:
self.log.debug('Savepoint %s.', savepoint_id)
query = 'SAVEPOINT "%s"' % savepoint_id
self.sql.execute(query)