Add logging for module registration
This commit is contained in:
parent
f5e427614b
commit
c43978bea2
|
@ -15,8 +15,6 @@ var Logger = require('./logger'),
|
||||||
Config = require('./config'),
|
Config = require('./config'),
|
||||||
Utils = require('./utils');
|
Utils = require('./utils');
|
||||||
|
|
||||||
Logger.setup();
|
|
||||||
|
|
||||||
var Cylon = module.exports = {
|
var Cylon = module.exports = {
|
||||||
Logger: Logger,
|
Logger: Logger,
|
||||||
Driver: require('./driver'),
|
Driver: require('./driver'),
|
||||||
|
|
|
@ -75,3 +75,6 @@ var setLogLevel = function(level) {
|
||||||
Logger[level] = function() {};
|
Logger[level] = function() {};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.setup();
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var Logger = require('./logger');
|
||||||
|
|
||||||
var missingModuleError = function(module) {
|
var missingModuleError = function(module) {
|
||||||
var string = "Cannot find the '" + module + "' module.\n";
|
var string = "Cannot find the '" + module + "' module.\n";
|
||||||
string += "This problem might be fixed by installing it with 'npm install " + module + "' and trying again.";
|
string += "This problem might be fixed by installing it with 'npm install " + module + "' and trying again.";
|
||||||
|
@ -44,14 +46,15 @@ var Registry = module.exports = {
|
||||||
this.data[module] = {
|
this.data[module] = {
|
||||||
module: pkg,
|
module: pkg,
|
||||||
adaptors: pkg.adaptors || [],
|
adaptors: pkg.adaptors || [],
|
||||||
drivers: pkg.drivers || []
|
drivers: pkg.drivers || [],
|
||||||
|
dependencies: pkg.dependencies || []
|
||||||
};
|
};
|
||||||
|
|
||||||
if (pkg.dependencies && Array.isArray(pkg.dependencies)) {
|
this.logRegistration(module, this.data[module]);
|
||||||
pkg.dependencies.forEach(function(dep) {
|
|
||||||
Registry.register(dep);
|
this.data[module].dependencies.forEach(function(dep) {
|
||||||
});
|
Registry.register(dep);
|
||||||
}
|
});
|
||||||
|
|
||||||
return this.data[module].module;
|
return this.data[module].module;
|
||||||
},
|
},
|
||||||
|
@ -72,6 +75,21 @@ var Registry = module.exports = {
|
||||||
return this.data[module].module;
|
return this.data[module].module;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
logRegistration: function(name) {
|
||||||
|
var module = this.data[name];
|
||||||
|
|
||||||
|
Logger.debug("Registering module " + name);
|
||||||
|
|
||||||
|
['adaptors', 'drivers', 'dependencies'].forEach(function(field) {
|
||||||
|
if (module[field].length) {
|
||||||
|
Logger.debug(" " + field + ":");
|
||||||
|
module[field].forEach(function(item) {
|
||||||
|
Logger.debug(" - " + item);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
search: function(entry, value) {
|
search: function(entry, value) {
|
||||||
for (var name in this.data) {
|
for (var name in this.data) {
|
||||||
var repo = this.data[name];
|
var repo = this.data[name];
|
||||||
|
|
|
@ -28,7 +28,8 @@ describe("Registry", function() {
|
||||||
"./../spec/support/mock_module.js": {
|
"./../spec/support/mock_module.js": {
|
||||||
module: module,
|
module: module,
|
||||||
drivers: ['test-driver'],
|
drivers: ['test-driver'],
|
||||||
adaptors: ['test-adaptor']
|
adaptors: ['test-adaptor'],
|
||||||
|
dependencies: []
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue