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'),
|
||||
Utils = require('./utils');
|
||||
|
||||
Logger.setup();
|
||||
|
||||
var Cylon = module.exports = {
|
||||
Logger: Logger,
|
||||
Driver: require('./driver'),
|
||||
|
|
|
@ -75,3 +75,6 @@ var setLogLevel = function(level) {
|
|||
Logger[level] = function() {};
|
||||
});
|
||||
}
|
||||
|
||||
Logger.setup();
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
var Logger = require('./logger');
|
||||
|
||||
var missingModuleError = function(module) {
|
||||
var string = "Cannot find the '" + module + "' module.\n";
|
||||
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] = {
|
||||
module: pkg,
|
||||
adaptors: pkg.adaptors || [],
|
||||
drivers: pkg.drivers || []
|
||||
drivers: pkg.drivers || [],
|
||||
dependencies: pkg.dependencies || []
|
||||
};
|
||||
|
||||
if (pkg.dependencies && Array.isArray(pkg.dependencies)) {
|
||||
pkg.dependencies.forEach(function(dep) {
|
||||
this.logRegistration(module, this.data[module]);
|
||||
|
||||
this.data[module].dependencies.forEach(function(dep) {
|
||||
Registry.register(dep);
|
||||
});
|
||||
}
|
||||
|
||||
return this.data[module].module;
|
||||
},
|
||||
|
@ -72,6 +75,21 @@ var Registry = module.exports = {
|
|||
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) {
|
||||
for (var name in this.data) {
|
||||
var repo = this.data[name];
|
||||
|
|
|
@ -28,7 +28,8 @@ describe("Registry", function() {
|
|||
"./../spec/support/mock_module.js": {
|
||||
module: module,
|
||||
drivers: ['test-driver'],
|
||||
adaptors: ['test-adaptor']
|
||||
adaptors: ['test-adaptor'],
|
||||
dependencies: []
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue