diff --git a/lib/lwm2m-server.js b/lib/lwm2m-server.js index 108e6cf..ff69265 100644 --- a/lib/lwm2m-server.js +++ b/lib/lwm2m-server.js @@ -133,7 +133,7 @@ function start(config, startCallback) { async.waterfall([ apply(validateTypes, config), - apply(registry.init, config, context, logger), + apply(registry.init, config), apply(coapRouter.start, config), loadDefaults ], function (error, results) { diff --git a/lib/services/server/inMemoryDeviceRegistry.js b/lib/services/server/inMemoryDeviceRegistry.js index 8ffe6f8..8a46980 100644 --- a/lib/services/server/inMemoryDeviceRegistry.js +++ b/lib/services/server/inMemoryDeviceRegistry.js @@ -27,8 +27,10 @@ var registry = {}, idCounter = 1, errors = require('../../errors'), _ = require('underscore'), - context, - logger, + logger = require('logops'), + context = { + op: 'LWM2MLib.MemoryDeviceRegistry' + }, checkLifetimeInterval; /** @@ -195,13 +197,12 @@ function stopLifetimeCheck() { * Initializes the device registry based on the parameter found in the configuration. For this in memory registry this * function doesn't do anything. * - * @param {Object} newConfig Configuration object. - * @param {Object} newContext Context object. - * @param {Object} newLogger Logger object. + * @param {Object} config Configuration object. */ -function init(newConfig, newContext, newLogger, callback) { - context = newContext; - logger = newLogger; +function init(config, callback) { + if (config.logLevel) { + logger.setLevel(config.logLevel); + } callback(null); } diff --git a/lib/services/server/mongodbDeviceRegistry.js b/lib/services/server/mongodbDeviceRegistry.js index 24d84bd..ae507f8 100644 --- a/lib/services/server/mongodbDeviceRegistry.js +++ b/lib/services/server/mongodbDeviceRegistry.js @@ -26,8 +26,10 @@ var errors = require('../../errors'), dbService = require('../model/dbConn'), Device = require('../model/Device'), - context, - logger, + logger = require('logops'), + context = { + op: 'LWM2MLib.MomgodbDeviceRegistry' + }, checkLifetimeInterval; /** @@ -244,14 +246,13 @@ function stopLifetimeCheck() { * The configuration object to use should be the one corresponding to the general server configuration, although all * the Mongo specific information should be stored under the 'deviceRegistry' section. * - * @param {Object} newConfig Configuration object containing a deviceRegistry attribute with the info. - * @param {Object} newContext Context object. - * @param {Object} newLogger Logger object. + * @param {Object} config Configuration object containing a deviceRegistry attribute with the info. */ -function init(newConfig, newContext, newLogger, callback) { - context = newContext; - logger = newLogger; - dbService.init(newConfig.deviceRegistry.host, newConfig.deviceRegistry.db, callback); +function init(config, callback) { + if (config.logLevel) { + logger.setLevel(config.logLevel); + } + dbService.init(config.deviceRegistry.host, config.deviceRegistry.db, callback); } exports.register = register;