diff --git a/lib/component.js b/lib/component.js index d9a5077a..66ed88a8 100644 --- a/lib/component.js +++ b/lib/component.js @@ -12,10 +12,12 @@ define( './advice', './utils', './compose', - './registry' + './registry', + './logger', + '../tools/debug/debug' ], - function(advice, utils, compose, registry) { + function(advice, utils, compose, registry, withLogging, debug) { var functionNameRegEx = /function (.*?)\s?\(/; var componentId = 0; @@ -91,7 +93,7 @@ define( type = event.type || event; - if (window.DEBUG && window.DEBUG.enabled && window.postMessage) { + if (debug.enabled && window.postMessage) { checkSerializable.call(this, type, data); } @@ -224,7 +226,7 @@ define( function define(/*mixins*/) { // unpacking arguments by hand benchmarked faster var l = arguments.length; - var mixins = new Array(l); + var mixins = new Array(l + 3); //add three for common mixins for (var i = 0; i < l; i++) mixins[i] = arguments[i]; Component.toString = function() { @@ -240,7 +242,7 @@ define( return prettyPrintMixins; }; - if (window.DEBUG && window.DEBUG.enabled) { + if (debug.enabled) { Component.describe = Component.toString(); } @@ -262,7 +264,7 @@ define( } this.toString = Component.toString; - if (window.DEBUG && window.DEBUG.enabled) { + if (debug.enabled) { this.describe = this.toString(); } @@ -289,8 +291,10 @@ define( Component.teardownAll = teardownAll; // prepend common mixins to supplied list, then mixin all flavors + if (debug.enabled) { + mixins.unshift(withLogging); + } mixins.unshift(withBaseComponent, advice.withAdvice, registry.withRegistration); - compose.mixin(Component.prototype, mixins); return Component; diff --git a/lib/logger.js b/lib/logger.js index 2c89b1bd..d2e7a341 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -68,14 +68,12 @@ define( action, '[' + name + ']', elemToString(elem), - component.constructor.toString(), - fn && (fnName = fn.name || fn.displayName) && '-> ' + fnName + component.constructor.describe.split(' ').slice(0,3).join(' ') //two mixins only ); } } } - function withLogging() { this.before('trigger', function() { log('trigger', this, util.toArray(arguments));