Sfoglia il codice sorgente

feat(lib/event): 为 event 模块增加调试日志

dzp 2 anni fa
parent
commit
cd7f0417e1
1 ha cambiato i file con 10 aggiunte e 0 eliminazioni
  1. 10 0
      plugins/lib/event.tin

+ 10 - 0
plugins/lib/event.tin

@@ -147,9 +147,11 @@ PaoTin++ © 2020~2023 的所有版权均由担子炮(dzp <danzipao@gmail.com>) 
     };
 
     #if { &gEventHandlers[$name][] <= 0 } {
+        dbgLog event => 事件「$name」已产生,但因为没有注册接受者所以无法投递。;
         #return;
     };
 
+    #local delivered {false};
     #local hook {};
     #foreach {*gEventHandlers[$name][]} {hook} {
         #local options  {$gEventHandlers[$name][$hook][options]};
@@ -158,6 +160,10 @@ PaoTin++ © 2020~2023 的所有版权均由担子炮(dzp <danzipao@gmail.com>) 
         #if { "$pHook" != "" && "$hook" != "$pHook" } {
             #continue;
         };
+
+        #local delivered {true};
+        dbgLog event => 事件「$name」即将投递给「$gEventHandlers[$name][$hook][module]」模块的「$hook」。;
+
         #if { "$options[justOnce]" == "true" } {
             #unvar {gEventHandlers[$name][$hook]};
         };
@@ -168,6 +174,10 @@ PaoTin++ © 2020~2023 的所有版权均由担子炮(dzp <danzipao@gmail.com>) 
             $code {$args};
         };
     };
+
+    #if { @isFalse{$delivered} } {
+        dbgLog event => 事件「$name」已产生,但因为没有匹配的接受者所以无法投递。;
+    };
 };
 
 ///=== {