1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #1818 from node-red-hitachi/context-store-logging

Add logging of context store
This commit is contained in:
Nick O'Leary 2018-07-20 20:23:32 +01:00 committed by GitHub
commit ab0fc2ecfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 6 deletions

View File

@ -90,7 +90,6 @@ function start() {
})
.then(function() { return storage.init(runtime)})
.then(function() { return settings.load(storage)})
.then(function() { return redNodes.loadContextsPlugin()})
.then(function() {
if (log.metric()) {
@ -163,8 +162,10 @@ function start() {
if (settings.httpStatic) {
log.info(log._("runtime.paths.httpStatic",{path:path.resolve(settings.httpStatic)}));
}
redNodes.loadContextsPlugin().then(function () {
redNodes.loadFlows().then(redNodes.startFlows).catch(function(err) {});
started = true;
});
}).catch(function(err) {
console.log(err);
});

View File

@ -163,7 +163,9 @@
"error-module-not-defined": "'module' is not defined in '__storage__' of settings.contextStorage",
"error-invalid-module-name": "Invalid context store name: '__name__'",
"error-invalid-default-module": "Invalid storage '__storage__' is specified as a default storage",
"error-use-undefined-storage": "Undefined storage '__storage__' is specified"
"error-use-undefined-storage": "Undefined storage '__storage__' is specified",
"unknown-store": "Unknown store '__name__' specified. Use default store instead.",
"log-store-init": "Context store : '__name__' [__info__]"
}
}

View File

@ -31,6 +31,26 @@ var defaultStore;
// Whether there context storage has been configured or left as default
var hasConfiguredStore = false;
// Unknown Stores
var unknownStores = {};
function logUnknownStore(name) {
if (name) {
var count = unknownStores[name] || 0;
if (count == 0) {
log.warn(log._("context.unknown-store", {name: name}));
count++;
unknownStores[name] = count;
}
}
}
function logStore(name, module) {
if (name !== '_') { // ignore default store
log.info(log._("context.log-store-init",
{name:name, info:"module="+module}));
}
}
function init(_settings) {
settings = _settings;
@ -93,6 +113,7 @@ function load() {
try {
// Create a new instance of the plugin by calling its module function
stores[pluginName] = plugin(config);
logStore(pluginName, plugins[pluginName].module);
} catch(err) {
return reject(new Error(log._("context.error-loading-module",{module:pluginName,message:err.toString()})));
}
@ -158,6 +179,7 @@ function getContextStorage(storage) {
return stores[storage];
} else if (stores.hasOwnProperty("_")) {
// Not known, but we have a default to fall back to
logUnknownStore(storage);
return stores["_"];
} else {
// Not known and no default configured

View File

@ -124,7 +124,6 @@ Memory.prototype._export = function() {
return this.data;
}
module.exports = function(config){
return new Memory(config);
};

View File

@ -901,4 +901,5 @@ describe('context', function() {
});
});
});
});

View File

@ -478,7 +478,7 @@ describe('localfilesystem',function() {
});
});
describe('if cache is enabled',function() {
describe('#if cache is enabled',function() {
afterEach(function() {
return context.clean([]).then(function(){
return context.close().then(function(){