From 51b7b1dea0fc169d32ef917d6a3321a6d33d87ca Mon Sep 17 00:00:00 2001 From: liabru Date: Thu, 4 Aug 2016 00:54:31 +0100 Subject: [PATCH] added plugin status logging --- src/core/Common.js | 6 +++--- src/core/Plugin.js | 14 +++++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/core/Common.js b/src/core/Common.js index bef7025..b927444 100644 --- a/src/core/Common.js +++ b/src/core/Common.js @@ -323,7 +323,7 @@ module.exports = Common; */ Common.log = function() { if (console && Common.logLevel > 0 && Common.logLevel <= 3) { - console.log.apply(console, [Matter.name + ':'].concat(Array.prototype.slice.call(arguments))); + console.log.apply(console, ['matter-js:'].concat(Array.prototype.slice.call(arguments))); } }; @@ -335,7 +335,7 @@ module.exports = Common; */ Common.info = function() { if (console && Common.logLevel > 0 && Common.logLevel <= 2) { - console.info.apply(console, [Matter.name + ':'].concat(Array.prototype.slice.call(arguments))); + console.info.apply(console, ['matter-js:'].concat(Array.prototype.slice.call(arguments))); } }; @@ -347,7 +347,7 @@ module.exports = Common; */ Common.warn = function() { if (console && Common.logLevel > 0 && Common.logLevel <= 3) { - console.warn.apply(console, [Matter.name + ':'].concat(Array.prototype.slice.call(arguments))); + console.warn.apply(console, ['matter-js:'].concat(Array.prototype.slice.call(arguments))); } }; diff --git a/src/core/Plugin.js b/src/core/Plugin.js index 6651d43..1585cce 100644 --- a/src/core/Plugin.js +++ b/src/core/Plugin.js @@ -75,10 +75,9 @@ var Common = require('./Common'); } var dependencies = Plugin.trackDependencies(base), - sortedDependencies = Common.topologicalSort(dependencies); + sortedDependencies = Common.topologicalSort(dependencies), + status = []; - console.log(dependencies, sortedDependencies); - for (var i = 0; i < sortedDependencies.length; i += 1) { if (sortedDependencies[i] === base.name) { continue; @@ -86,22 +85,27 @@ var Common = require('./Common'); var plugin = Plugin.resolve(sortedDependencies[i]); + if (!plugin) { + status.push('❌ ' + sortedDependencies[i]); + } + if (!plugin || Plugin.isUsed(base, plugin.name)) { continue; } if (!Plugin.isFor(plugin, base)) { - Common.log('Plugin.installDependencies: ' + Plugin.toString(plugin) + ' is for ' + plugin.for + ' but installed on ' + Plugin.toString(base) + '.', 'warn'); + Common.warn('Plugin.installDependencies:', Plugin.toString(plugin), 'is for', plugin.for, 'but installed on', Plugin.toString(base) + '.'); } if (plugin.install) { plugin.install(base); + status.push('✅ ' + Plugin.toString(plugin)); } base.used.push(plugin.name); } - console.log(base.used); + Common.info('Plugin status:', status.join(', ')); }; Plugin.trackDependencies = function(base, tracked) {