diff --git a/src/debug.js b/src/debug.js new file mode 100644 index 00000000000..4b05eddae31 --- /dev/null +++ b/src/debug.js @@ -0,0 +1,16 @@ +import * as hooklib from "hooks"; + +function Debug(hooks) { + for (let k in hooklib) this[k] = hooklib[k]; + this.hooks = hooks; + + let self = this; + this.hooks.attach("debug", self); + + return this; +} + +/** Debug method, exposes debug hook */ +Debug.prototype.debug = function(data) {}; + +export default Debug; diff --git a/src/pattern.js b/src/pattern.js index 77bb285b169..1ec6d8bab10 100644 --- a/src/pattern.js +++ b/src/pattern.js @@ -8,6 +8,7 @@ import Svg from "./svg"; import Hooks from "./hooks"; import pack from "bin-pack"; import Store from "./store"; +import Debug from "./debug"; export default function Pattern(config = false) { // width and height properties @@ -67,7 +68,9 @@ Pattern.prototype.draft = function() { }; /** Debug method, exposes debug hook */ -Part.prototype.debug = function(data) {}; +Pattern.prototype.debug = function(data) { + this.dbg.debug(data); +}; Pattern.prototype.render = function() { this.svg = new Svg(this); @@ -83,7 +86,9 @@ Pattern.prototype.on = function(hook, method) { }; Pattern.prototype.with = function(plugin) { - console.log(plugin); + this.dbg = new Debug(this.hooks); + + this.debug(`Plugin: ${plugin.name} v${plugin.version}`); if (plugin.hooks) this.loadPluginHooks(plugin); if (plugin.macros) this.loadPluginMacros(plugin);