diff --git a/lib/cylon.js b/lib/cylon.js index 430d7d8..9e7cb9a 100644 --- a/lib/cylon.js +++ b/lib/cylon.js @@ -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'), diff --git a/lib/logger.js b/lib/logger.js index 3853553..cb8e2bb 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -75,3 +75,6 @@ var setLogLevel = function(level) { Logger[level] = function() {}; }); } + +Logger.setup(); + diff --git a/lib/registry.js b/lib/registry.js index 65420fa..b540da7 100644 --- a/lib/registry.js +++ b/lib/registry.js @@ -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) { - Registry.register(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]; diff --git a/spec/lib/registry.spec.js b/spec/lib/registry.spec.js index cffd331..88e841e 100644 --- a/spec/lib/registry.spec.js +++ b/spec/lib/registry.spec.js @@ -28,7 +28,8 @@ describe("Registry", function() { "./../spec/support/mock_module.js": { module: module, drivers: ['test-driver'], - adaptors: ['test-adaptor'] + adaptors: ['test-adaptor'], + dependencies: [] } }); });