[debug/dbglevel] add new dbglevel flag DBG_UICFG

authorLaurent Peuch <cortex@worlddomination.be>
changeset6874f361aa1b
branchdefault
phasedraft
hiddenno
parent revision#f316e4df5745 [debug] add mechanism to collect uicfg declarations
child revision#25b42cbd8c13 [debug/DBG_UICFG] add syntaxe highlight
files modified by this revision
cubicweb/cwctl.py
cubicweb/rtags.py
cubicweb/server/__init__.py
# HG changeset patch
# User Laurent Peuch <cortex@worlddomination.be>
# Date 1611742835 -3600
# Wed Jan 27 11:20:35 2021 +0100
# Node ID 6874f361aa1b57867a9abf1006dbe422e35dd936
# Parent f316e4df5745a1e1bc3e1e5ac6f2123afa7801e4
[debug/dbglevel] add new dbglevel flag DBG_UICFG

diff --git a/cubicweb/cwctl.py b/cubicweb/cwctl.py
@@ -46,11 +46,11 @@
1  from cubicweb.server import set_debug
2  from cubicweb.toolsutils import Command, rm, create_dir, underline_title
3  from cubicweb.__pkginfo__ import version as cw_version
4 
5  LOG_LEVELS = ('debug', 'info', 'warning', 'error')
6 -DBG_FLAGS = ('RQL', 'SQL', 'REPO', 'HOOKS', 'OPS', 'SEC', 'MORE', 'ALL')
7 +DBG_FLAGS = ('RQL', 'SQL', 'REPO', 'HOOKS', 'OPS', 'SEC', 'MORE', 'UICFG', 'ALL')
8 
9  # don't check duplicated commands, it occurs when reloading site_cubicweb
10  CWCTL = CommandLine('cubicweb-ctl', 'The CubicWeb swiss-knife.',
11                      version=cw_version, check_duplicated_command=False)
12 
diff --git a/cubicweb/rtags.py b/cubicweb/rtags.py
@@ -43,11 +43,11 @@
13  from collections import UserDict
14 
15  from logilab.common.logging_ext import set_log_methods
16  from logilab.common.registry import RegistrableInstance, yes
17 
18 -from cubicweb.server import DBG_UICFG
19 +from cubicweb import server
20 
21 
22  def _ensure_str_key(key):
23      return tuple(str(k) for k in key)
24 
@@ -127,10 +127,18 @@
25 
26      def __setitem__(self, key, value):
27          stack = inspect.stack()
28          declaration = self._get_declaration(stack, key, value)
29 
30 +        if declaration and (server.DEBUG & server.DBG_UICFG):
31 +            print('uicfg: add "%s" from "%s" at %s:%s' % (
32 +                ("%s = %s" % (declaration["key"], repr(declaration["value"]))).strip(),
33 +                "\n".join(declaration["inspect_frame"].code_context).strip(),
34 +                declaration["inspect_frame"].filename,
35 +                declaration["inspect_frame"].lineno,
36 +            ))
37 +
38          return super(DebugDict, self).__setitem__(key, value)
39 
40 
41  class RegistrableRtags(RegistrableInstance):
42      __registry__ = 'uicfg'
diff --git a/cubicweb/server/__init__.py b/cubicweb/server/__init__.py
@@ -61,22 +61,22 @@
43  DBG_RQL = 1
44  #: executed sql
45  DBG_SQL = 2
46  #: repository events
47  DBG_REPO = 4
48 +#: uicfg
49 +DBG_UICFG = 8
50  #: hooks
51  DBG_HOOKS = 16
52  #: operations
53  DBG_OPS = 32
54  #: security
55  DBG_SEC = 64
56  #: more verbosity
57  DBG_MORE = 128
58 -#: uicfg
59 -DBG_UICFG = 256
60  #: all level enabled
61 -DBG_ALL = DBG_RQL + DBG_SQL + DBG_REPO + DBG_HOOKS + DBG_OPS + DBG_SEC + DBG_MORE + DBG_UICFG
62 +DBG_ALL = DBG_RQL + DBG_SQL + DBG_REPO + DBG_UICFG + DBG_HOOKS + DBG_OPS + DBG_SEC + DBG_MORE
63 
64  _SECURITY_ITEMS = []
65  _SECURITY_CAPS = ['read', 'add', 'update', 'delete', 'transition']
66 
67  #: current debug mode