[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

authorLaurent Peuch <cortex@worlddomination.be>
changeset6e98699d3a9a
branchdefault
phasepublic
hiddenno
parent revision#c6f8ca03718f [debug] syntax highlight SQL and RQL debug output
child revision#90348f847b4b [pyramid/debug] on every request display request path and selected controller
files modified by this revision
cubicweb/server/session.py
# HG changeset patch
# User Laurent Peuch <cortex@worlddomination.be>
# Date 1566355928 -7200
# Wed Aug 21 04:52:08 2019 +0200
# Node ID 6e98699d3a9a4e7427a67d6f82639157e0854111
# Parent c6f8ca03718fa3554b46825c58982a195f5c9462
[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
@@ -672,10 +672,11 @@
1 
2      @_open_only
3      def rollback(self):
4          """rollback the current transaction"""
5          cnxset = self.cnxset
6 +        debug = server.DEBUG & server.DBG_OPS
7          assert cnxset is not None
8          try:
9              # by default, operations are executed with security turned off
10              with self.security_enabled(False, False):
11                  while self.pending_operations:
@@ -684,11 +685,12 @@
12                          operation.handle_event('rollback_event')
13                      except BaseException:
14                          self.critical('rollback error', exc_info=sys.exc_info())
15                          continue
16                  cnxset.rollback()
17 -                self.debug('rollback for transaction %s done', self)
18 +                if debug:
19 +                    print('rollback for transaction %s done' % self)
20          finally:
21              self.clear()
22 
23      @_open_only
24      def commit(self):
@@ -724,11 +726,12 @@
25                              processed.append(operation)
26                              if debug:
27                                  print(operation)
28                              operation.handle_event('precommit_event')
29                      self.pending_operations[:] = processed
30 -                    self.debug('precommit transaction %s done', self)
31 +                    if debug:
32 +                        print('precommit transaction %s done' % self)
33                  except BaseException:
34                      # if error on [pre]commit:
35                      #
36                      # * set .failed = True on the operation causing the failure
37                      # * call revert<event>_event on processed operations
@@ -770,11 +773,12 @@
38                          except BaseException:
39                              if self.repo.config.mode == 'test':
40                                  raise
41                              self.critical('error while postcommit',
42                                            exc_info=sys.exc_info())
43 -                self.debug('postcommit transaction %s done', self)
44 +                if debug:
45 +                    print('postcommit transaction %s done' % self)
46                  return self.transaction_uuid(set=False)
47          finally:
48              self.clear()
49 
50      # resource accessors ######################################################