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:
commit
ab0fc2ecfa
@ -90,7 +90,6 @@ function start() {
|
|||||||
})
|
})
|
||||||
.then(function() { return storage.init(runtime)})
|
.then(function() { return storage.init(runtime)})
|
||||||
.then(function() { return settings.load(storage)})
|
.then(function() { return settings.load(storage)})
|
||||||
.then(function() { return redNodes.loadContextsPlugin()})
|
|
||||||
.then(function() {
|
.then(function() {
|
||||||
|
|
||||||
if (log.metric()) {
|
if (log.metric()) {
|
||||||
@ -163,8 +162,10 @@ function start() {
|
|||||||
if (settings.httpStatic) {
|
if (settings.httpStatic) {
|
||||||
log.info(log._("runtime.paths.httpStatic",{path:path.resolve(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) {});
|
redNodes.loadFlows().then(redNodes.startFlows).catch(function(err) {});
|
||||||
started = true;
|
started = true;
|
||||||
|
});
|
||||||
}).catch(function(err) {
|
}).catch(function(err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
|
@ -163,7 +163,9 @@
|
|||||||
"error-module-not-defined": "'module' is not defined in '__storage__' of settings.contextStorage",
|
"error-module-not-defined": "'module' is not defined in '__storage__' of settings.contextStorage",
|
||||||
"error-invalid-module-name": "Invalid context store name: '__name__'",
|
"error-invalid-module-name": "Invalid context store name: '__name__'",
|
||||||
"error-invalid-default-module": "Invalid storage '__storage__' is specified as a default storage",
|
"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__]"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,26 @@ var defaultStore;
|
|||||||
// Whether there context storage has been configured or left as default
|
// Whether there context storage has been configured or left as default
|
||||||
var hasConfiguredStore = false;
|
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) {
|
function init(_settings) {
|
||||||
settings = _settings;
|
settings = _settings;
|
||||||
@ -93,6 +113,7 @@ function load() {
|
|||||||
try {
|
try {
|
||||||
// Create a new instance of the plugin by calling its module function
|
// Create a new instance of the plugin by calling its module function
|
||||||
stores[pluginName] = plugin(config);
|
stores[pluginName] = plugin(config);
|
||||||
|
logStore(pluginName, plugins[pluginName].module);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return reject(new Error(log._("context.error-loading-module",{module:pluginName,message:err.toString()})));
|
return reject(new Error(log._("context.error-loading-module",{module:pluginName,message:err.toString()})));
|
||||||
}
|
}
|
||||||
@ -158,6 +179,7 @@ function getContextStorage(storage) {
|
|||||||
return stores[storage];
|
return stores[storage];
|
||||||
} else if (stores.hasOwnProperty("_")) {
|
} else if (stores.hasOwnProperty("_")) {
|
||||||
// Not known, but we have a default to fall back to
|
// Not known, but we have a default to fall back to
|
||||||
|
logUnknownStore(storage);
|
||||||
return stores["_"];
|
return stores["_"];
|
||||||
} else {
|
} else {
|
||||||
// Not known and no default configured
|
// Not known and no default configured
|
||||||
|
@ -124,7 +124,6 @@ Memory.prototype._export = function() {
|
|||||||
return this.data;
|
return this.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = function(config){
|
module.exports = function(config){
|
||||||
return new Memory(config);
|
return new Memory(config);
|
||||||
};
|
};
|
||||||
|
@ -901,4 +901,5 @@ describe('context', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -478,7 +478,7 @@ describe('localfilesystem',function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('if cache is enabled',function() {
|
describe('#if cache is enabled',function() {
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
return context.clean([]).then(function(){
|
return context.clean([]).then(function(){
|
||||||
return context.close().then(function(){
|
return context.close().then(function(){
|
||||||
|
Loading…
Reference in New Issue
Block a user