Skip to content

Commit

Permalink
Issue #386 [Enhancement][WIP] Tracing can be disabled by skipping the…
Browse files Browse the repository at this point in the history
… call to setTracer()
  • Loading branch information
t2ym committed Oct 2, 2020
1 parent 7547bc4 commit 1fa4e46
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
27 changes: 21 additions & 6 deletions demo-config/Tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@ Copyright (c) 2020 Tetsuya Mori <t2y3141592@gmail.com>. All rights reserved.
const Traceable = (base) => class TraceableConfigBase extends base {
// this.assign('name')({ property: value, ... }).assign('name2')({ property: value, ... })...
assign(name) {
this.trace.currentPlugin = { name: `init:${name}` };
if (this.trace && this.trace.proxy) {
this.trace.currentPlugin = { name: `init:${name}` };
}
return (properties) => {
if (!this[name]) {
this[name] = properties;
}
else {
Object.assign(this[name], properties);
}
this.trace.currentPlugin = null;
if (name === 'trace') {
this.setProxyHandlers();
if (this.trace && this.trace.proxy) {
this.trace.currentPlugin = null;
if (name === 'trace') {
this.setProxyHandlers();
}
}
return this;
};
Expand Down Expand Up @@ -64,6 +68,9 @@ const Traceable = (base) => class TraceableConfigBase extends base {
setProxyHandlers() {
let targetConfig = this;
let trace = this.trace;
if (!(trace && trace.proxy)) {
return;
}
let traceMap = new Map();
let traceLog = trace.log;
let aggregations = trace.aggregations;
Expand Down Expand Up @@ -182,6 +189,9 @@ const Traceable = (base) => class TraceableConfigBase extends base {
}
setFsTracer() {
let trace = this.trace;
if (!(trace && trace.proxy)) {
return;
}
let traceLog = trace.log;
const aggregate = (path) => {
let base = this.path.base;
Expand Down Expand Up @@ -251,10 +261,15 @@ const Traceable = (base) => class TraceableConfigBase extends base {
}
pre(plugin) {
super.pre(plugin);
this.trace.currentPlugin = plugin;
if (this.trace && this.trace.proxy) {
this.trace.currentPlugin = plugin;
}
}
post(plugin) {
super.post(plugin);
super.post(plugin);
if (!(this.trace && this.trace.proxy)) {
return;
}
let traceLog = this.trace.log[plugin.name];
if (!traceLog) {
this.trace.log[plugin.name] = traceLog = new Set();
Expand Down
22 changes: 4 additions & 18 deletions demo-config/dependency-graph.dot
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,6 @@ digraph dependencies {
"this.thin-hook" -> "init:thin-hook"[color="0.002 0.999 0.999"]
"this.thin-hook.hook" -> "init:thin-hook"[color="0.002 0.999 0.999"]

"init:hook-min-js"[color="0.590 0.273 1.000"]
"this.hook-min-js" -> "init:hook-min-js"[color="0.002 0.999 0.999"]
"this.hook-min-js.searchParams" -> "init:hook-min-js"[color="0.002 0.999 0.999"]
"this.hook-min-js.targetTypes" -> "init:hook-min-js"[color="0.002 0.999 0.999"]

"init:inject"[color="0.590 0.273 1.000"]
"this.inject" -> "init:inject"[color="0.002 0.999 0.999"]
"this.inject.injectors" -> "init:inject"[color="0.002 0.999 0.999"]
"this.inject.entryPage" -> "init:inject"[color="0.002 0.999 0.999"]
"this.inject.emptyDocument" -> "init:inject"[color="0.002 0.999 0.999"]
"this.inject.iframe" -> "init:inject"[color="0.002 0.999 0.999"]
"this.inject.svg" -> "init:inject"[color="0.002 0.999 0.999"]
"this.inject.hookWorker" -> "init:inject"[color="0.002 0.999 0.999"]
"this.inject.dedicatedWorker" -> "init:inject"[color="0.002 0.999 0.999"]
"this.inject.dedicatedWorkerModule" -> "init:inject"[color="0.002 0.999 0.999"]
"this.inject.sharedWorker" -> "init:inject"[color="0.002 0.999 0.999"]

"init:url"[color="0.590 0.273 1.000"]
"this.url" -> "init:url"[color="0.002 0.999 0.999"]
"this.url.root" -> "init:url"[color="0.002 0.999 0.999"]
Expand Down Expand Up @@ -1775,7 +1758,10 @@ digraph dependencies {
"injector-helpers" -> "plugins/target-injector/package.json"
"injector-helpers" -> "this.gulp.series"
"injector-helpers" -> "this.gulp.task"
"this.inject.components" -> "injector-helpers"[color="0.002 0.999 0.999"]
"this.inject.components.HtmlInjectionHandlerFactory" -> "injector-helpers"[color="0.002 0.999 0.999"]
"this.inject.components.InjectionHandlerBase" -> "injector-helpers"[color="0.002 0.999 0.999"]
"this.inject.components.Injector" -> "injector-helpers"[color="0.002 0.999 0.999"]
"this.inject.components.JsInjectionHandlerFactory" -> "injector-helpers"[color="0.002 0.999 0.999"]
"this.injector-helpers.done" -> "injector-helpers"[color="0.002 0.999 0.999"]
"injector-helpers" -> "this.path.base"
"injector-helpers" -> "this.path.config"
Expand Down

0 comments on commit 1fa4e46

Please sign in to comment.