0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-23 09:26:51 -05:00

added plugin status logging

This commit is contained in:
liabru 2016-08-04 00:54:31 +01:00
parent d4d64edaa1
commit 51b7b1dea0
2 changed files with 12 additions and 8 deletions

View file

@ -323,7 +323,7 @@ module.exports = Common;
*/ */
Common.log = function() { Common.log = function() {
if (console && Common.logLevel > 0 && Common.logLevel <= 3) { 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() { Common.info = function() {
if (console && Common.logLevel > 0 && Common.logLevel <= 2) { 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() { Common.warn = function() {
if (console && Common.logLevel > 0 && Common.logLevel <= 3) { 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)));
} }
}; };

View file

@ -75,9 +75,8 @@ var Common = require('./Common');
} }
var dependencies = Plugin.trackDependencies(base), 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) { for (var i = 0; i < sortedDependencies.length; i += 1) {
if (sortedDependencies[i] === base.name) { if (sortedDependencies[i] === base.name) {
@ -86,22 +85,27 @@ var Common = require('./Common');
var plugin = Plugin.resolve(sortedDependencies[i]); var plugin = Plugin.resolve(sortedDependencies[i]);
if (!plugin) {
status.push('❌ ' + sortedDependencies[i]);
}
if (!plugin || Plugin.isUsed(base, plugin.name)) { if (!plugin || Plugin.isUsed(base, plugin.name)) {
continue; continue;
} }
if (!Plugin.isFor(plugin, base)) { 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) { if (plugin.install) {
plugin.install(base); plugin.install(base);
status.push('✅ ' + Plugin.toString(plugin));
} }
base.used.push(plugin.name); base.used.push(plugin.name);
} }
console.log(base.used); Common.info('Plugin status:', status.join(', '));
}; };
Plugin.trackDependencies = function(base, tracked) { Plugin.trackDependencies = function(base, tracked) {