[PATCH 6 of 7] [logging/debug] move transaction operations logs from self.debug to DBG_OPS

Laurent Peuch cortex at worlddomination.be
Sun Sep 1 04:07:02 CEST 2019


# HG changeset patch
# User Laurent Peuch <cortex at worlddomination.be>
# Date 1566355928 -7200
#      Wed Aug 21 04:52:08 2019 +0200
# Node ID d1b93478bdb4e8bddf19288ff29c67a6495fb02f
# Parent  17465c0ba7998d52ab5b2b2155b411c24da039e9
[logging/debug] move transaction operations logs from self.debug to DBG_OPS

There were a mixing between displaying transaction operations log on
logger.debug and only when DBG_OPS was on, uniformize everything behind
DBG_OPS.

Closes #17229126

diff --git a/cubicweb/server/session.py b/cubicweb/server/session.py
--- a/cubicweb/server/session.py
+++ b/cubicweb/server/session.py
@@ -674,6 +674,7 @@ class Connection(RequestSessionBase):
     def rollback(self):
         """rollback the current transaction"""
         cnxset = self.cnxset
+        debug = server.DEBUG & server.DBG_OPS
         assert cnxset is not None
         try:
             # by default, operations are executed with security turned off
@@ -686,7 +687,8 @@ class Connection(RequestSessionBase):
                         self.critical('rollback error', exc_info=sys.exc_info())
                         continue
                 cnxset.rollback()
-                self.debug('rollback for transaction %s done', self)
+                if debug:
+                    print('rollback for transaction %s done' % self)
         finally:
             self.clear()
 
@@ -726,7 +728,8 @@ class Connection(RequestSessionBase):
                                 print(operation)
                             operation.handle_event('precommit_event')
                     self.pending_operations[:] = processed
-                    self.debug('precommit transaction %s done', self)
+                    if debug:
+                        print('precommit transaction %s done' % self)
                 except BaseException:
                     # if error on [pre]commit:
                     #
@@ -772,7 +775,8 @@ class Connection(RequestSessionBase):
                                 raise
                             self.critical('error while postcommit',
                                           exc_info=sys.exc_info())
-                self.debug('postcommit transaction %s done', self)
+                if debug:
+                    print('postcommit transaction %s done' % self)
                 return self.transaction_uuid(set=False)
         finally:
             self.clear()



More information about the cubicweb-devel mailing list