mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] tooling: debug tool logged too many scheduler stops
This was caused by additional calls to flush (because of connected components) closes #533
This commit is contained in:
+1
-1
@@ -91,7 +91,7 @@ logging useful information is extremely valuable. There is a [javascript file](.
|
||||
Once it is executed, it will log a lot of information on each component main hooks. The following code is a minified version to make it easier to copy/paste:
|
||||
|
||||
```
|
||||
function debugOwl(o,t){let e,n="[OWL_DEBUG]";function l(o){let t=JSON.stringify(o||{});return t.length>200&&(t=t.slice(0,200)+"..."),t}if(Object.defineProperty(o.Component,"current",{get:()=>e,set(s){e=s;const c=s.constructor.name;if(t.componentBlackList&&t.componentBlackList.test(c))return;if(t.componentWhiteList&&!t.componentWhiteList.test(c))return;let r;Object.defineProperty(e,"__owl__",{get:()=>r,set(e){!function(e,s,c){let r=`${s}<id=${c}>`,i=o=>(!t.methodBlackList||!t.methodBlackList.includes(o))&&!(t.methodWhiteList&&!t.methodWhiteList.includes(o));i("constructor")&&console.log(`${n} ${r} constructor, props=${l(e.props)}`);i("willStart")&&o.hooks.onWillStart(()=>{console.log(`${n} ${r} willStart`)});i("mounted")&&o.hooks.onMounted(()=>{console.log(`${n} ${r} mounted`)});i("willUpdateProps")&&o.hooks.onWillUpdateProps(o=>{console.log(`${n} ${r} willUpdateProps, nextprops=${l(o)}`)});i("willPatch")&&o.hooks.onWillPatch(()=>{console.log(`${n} ${r} willPatch`)});i("patched")&&o.hooks.onPatched(()=>{console.log(`${n} ${r} patched`)});i("willUnmount")&&o.hooks.onWillUnmount(()=>{console.log(`${n} ${r} willUnmount`)});const u=e.__render.bind(e);e.__render=function(...o){console.log(`${n} ${r} rendering template`),u(...o)};const d=e.render.bind(e);e.render=function(...o){return console.log(`${n} ${r} render`),d(...o)};const p=e.mount.bind(e);e.mount=function(...o){return console.log(`${n} ${r} mount`),p(...o)}}(s,c,(r=e).id)}})}}),t.logScheduler){let t=o.Component.scheduler.start,e=o.Component.scheduler.stop;o.Component.scheduler.start=function(){console.log(`${n} scheduler: start running tasks queue`),t.call(this)},o.Component.scheduler.stop=function(){console.log(`${n} scheduler: stop running tasks queue`),e.call(this)}}if(t.logStore){let t=o.Store.prototype.dispatch;o.Store.prototype.dispatch=function(o,...e){return console.log(`${n} store: action '${o}' dispatched. Payload: '${l(e)}'`),t.call(this,o,...e)}}}
|
||||
function debugOwl(o,t){let e,n="[OWL_DEBUG]";function l(o){let t=JSON.stringify(o||{});return t.length>200&&(t=t.slice(0,200)+"..."),t}if(Object.defineProperty(o.Component,"current",{get:()=>e,set(s){e=s;const c=s.constructor.name;if(t.componentBlackList&&t.componentBlackList.test(c))return;if(t.componentWhiteList&&!t.componentWhiteList.test(c))return;let i;Object.defineProperty(e,"__owl__",{get:()=>i,set(e){!function(e,s,c){let i=`${s}<id=${c}>`,r=o=>(!t.methodBlackList||!t.methodBlackList.includes(o))&&!(t.methodWhiteList&&!t.methodWhiteList.includes(o));r("constructor")&&console.log(`${n} ${i} constructor, props=${l(e.props)}`);r("willStart")&&o.hooks.onWillStart(()=>{console.log(`${n} ${i} willStart`)});r("mounted")&&o.hooks.onMounted(()=>{console.log(`${n} ${i} mounted`)});r("willUpdateProps")&&o.hooks.onWillUpdateProps(o=>{console.log(`${n} ${i} willUpdateProps, nextprops=${l(o)}`)});r("willPatch")&&o.hooks.onWillPatch(()=>{console.log(`${n} ${i} willPatch`)});r("patched")&&o.hooks.onPatched(()=>{console.log(`${n} ${i} patched`)});r("willUnmount")&&o.hooks.onWillUnmount(()=>{console.log(`${n} ${i} willUnmount`)});const u=e.__render.bind(e);e.__render=function(...o){console.log(`${n} ${i} rendering template`),u(...o)};const d=e.render.bind(e);e.render=function(...o){return console.log(`${n} ${i} render`),d(...o)};const h=e.mount.bind(e);e.mount=function(...o){return console.log(`${n} ${i} mount`),h(...o)}}(s,c,(i=e).id)}})}}),t.logScheduler){let t=o.Component.scheduler.start,e=o.Component.scheduler.stop;o.Component.scheduler.start=function(){this.isRunning||console.log(`${n} scheduler: start running tasks queue`),t.call(this)},o.Component.scheduler.stop=function(){this.isRunning&&console.log(`${n} scheduler: stop running tasks queue`),e.call(this)}}if(t.logStore){let t=o.Store.prototype.dispatch;o.Store.prototype.dispatch=function(o,...e){return console.log(`${n} store: action '${o}' dispatched. Payload: '${l(e)}'`),t.call(this,o,...e)}}}
|
||||
debugOwl(owl, {
|
||||
// componentBlackList: /App/, // regexp
|
||||
// componentWhiteList: /SomeComponent/, // regexp
|
||||
|
||||
+6
-2
@@ -107,11 +107,15 @@
|
||||
let start = owl.Component.scheduler.start;
|
||||
let stop = owl.Component.scheduler.stop;
|
||||
owl.Component.scheduler.start = function () {
|
||||
console.log(`${prefix} scheduler: start running tasks queue`);
|
||||
if (!this.isRunning) {
|
||||
console.log(`${prefix} scheduler: start running tasks queue`);
|
||||
}
|
||||
start.call(this);
|
||||
};
|
||||
owl.Component.scheduler.stop = function () {
|
||||
console.log(`${prefix} scheduler: stop running tasks queue`);
|
||||
if (this.isRunning) {
|
||||
console.log(`${prefix} scheduler: stop running tasks queue`);
|
||||
}
|
||||
stop.call(this);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user