Revision: 3666
Author: felix8a
Date: Thu Aug 27 13:42:45 2009
Log: squelch domita event logging
http://codereview.appspot.com/110099

right now, domita emits a log message for every event dispatched,
which is a lot of noise when there are mouseover or mousemove handlers.

this change squelches those log messages unless a gadget
calls setDomitaTrace(1);

[email protected]

http://code.google.com/p/google-caja/source/detail?r=3666

Modified:
 /trunk/src/com/google/caja/plugin/domita.js

=======================================
--- /trunk/src/com/google/caja/plugin/domita.js Thu Aug 27 13:38:20 2009
+++ /trunk/src/com/google/caja/plugin/domita.js Thu Aug 27 13:42:45 2009
@@ -3580,6 +3580,16 @@
       return idClass;
     };

+    // bitmask of trace points
+    //    0x0001 plugin_dispatchEvent
+    imports.domitaTrace___ = 0;
+    imports.getDomitaTrace = ___.markFuncFreeze(
+        function () { return imports.domitaTrace___; }
+    );
+    imports.setDomitaTrace = ___.markFuncFreeze(
+        function (x) { imports.domitaTrace___ = x; }
+    );
+
     // TODO(mikesamuel): remove these, and only expose them via window once
     // Valija works
     imports.setTimeout = tameSetTimeout;
@@ -4016,13 +4026,15 @@
 function plugin_dispatchEvent___(thisNode, event, pluginId, handler) {
   event = (event || window.event);
   var sig = String(handler).match(/^function\b[^\)]*\)/);
-  cajita.log(
-      'Dispatch ' + (event && event.type) +
-      'event thisNode=' + thisNode + ', ' +
-      'event=' + event + ', ' +
-      'pluginId=' + pluginId + ', ' +
-      'handler=' + (sig ? sig[0] : handler));
   var imports = ___.getImports(pluginId);
+  if (imports.domitaTrace___ & 0x1) {
+    cajita.log(
+        'Dispatch ' + (event && event.type) +
+        'event thisNode=' + thisNode + ', ' +
+        'event=' + event + ', ' +
+        'pluginId=' + pluginId + ', ' +
+        'handler=' + (sig ? sig[0] : handler));
+  }
   switch (typeof handler) {
     case 'string':
       handler = imports[handler];

Reply via email to