소스 검색

Adding a core hook that generate debug log listing registered hooks

Yann Weber 8 년 전
부모
커밋
748850cf33
1개의 변경된 파일20개의 추가작업 그리고 1개의 파일을 삭제
  1. 20
    1
      lodel/plugin/core_hooks.py

+ 20
- 1
lodel/plugin/core_hooks.py 파일 보기

@@ -9,7 +9,7 @@ from lodel import logger
9 9
 
10 10
 ##@brief Bootstrap hook to check datasources configuration
11 11
 @LodelHook('lodel2_bootstraped')
12
-def datasources_bootstrap_callaback(hook_name, caller, payload):
12
+def datasources_bootstrap_hook(hook_name, caller, payload):
13 13
     for ds_name in Settings.datasources._fields:
14 14
         ds_conf = getattr(Settings.datasources, ds_name)
15 15
         identifier = getattr(ds_conf, 'identifier')
@@ -34,6 +34,25 @@ def datasources_bootstrap_callaback(hook_name, caller, payload):
34 34
         log_msg %= (ds_name, identifier)
35 35
         logger.debug(log_msg)
36 36
 
37
+##@brief Bootstrap hook that print debug infos about registered hooks
38
+@LodelHook('lodel2_bootstraped')
39
+def list_hook_debug_hook(name, caller, payload):
40
+    from lodel.auth.auth import Auth
41
+    from lodel import logger
42
+    hlist = LodelHook.hook_list()
43
+    for name, reg_hooks in hlist.items():
44
+        for hook, priority in reg_hooks:
45
+            logger.debug("{modname}.{funname} is registered as hook \
46
+{hookname} with priority {priority}".format(
47
+                modname = hook.__module__,
48
+                funname = hook.__name__,
49
+                priority = priority,
50
+                hookname = name))
51
+            
52
+        
53
+
54
+
55
+##@brief Hooks that trigger custom methods injection in dynmic classes
37 56
 @LodelHook("lodel2_dyncode_loaded")
38 57
 def lodel2_plugins_custom_methods(self, caller, dynclasses):
39 58
     from lodel.plugin.plugins import CustomMethod

Loading…
취소
저장