mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Logs internationalisation
This commit is contained in:
parent
cc760acb62
commit
6c766eba86
44
packages/node_modules/node-red/red.js
vendored
44
packages/node_modules/node-red/red.js
vendored
@ -141,21 +141,17 @@ if (process.env.NODE_RED_ENABLE_PROJECTS) {
|
||||
settings.editorTheme.projects = settings.editorTheme.projects || {};
|
||||
settings.editorTheme.projects.enabled = !/^false$/i.test(process.env.NODE_RED_ENABLE_PROJECTS);
|
||||
}
|
||||
debugger;
|
||||
|
||||
var httpsPromise;
|
||||
if (settings.https) {
|
||||
var startupHttps = settings.https;
|
||||
// Delay logging of (translated) messages until the RED object has been initialized
|
||||
var delayedLogItems = [];
|
||||
|
||||
if (typeof startupHttps === "function") {
|
||||
// Get the result of the function, because createServer doesn't accept functions as input
|
||||
startupHttps = startupHttps();
|
||||
}
|
||||
httpsPromise = Promise.resolve(startupHttps);
|
||||
}
|
||||
else {
|
||||
// No https is enable - wrap null
|
||||
httpsPromise = Promise.resolve(null);
|
||||
}
|
||||
var startupHttps = settings.https;
|
||||
if (typeof startupHttps === "function") {
|
||||
// Get the result of the function, because createServer doesn't accept functions as input
|
||||
startupHttps = startupHttps();
|
||||
}
|
||||
var httpsPromise = Promise.resolve(startupHttps);
|
||||
|
||||
httpsPromise.then(function(startupHttps) {
|
||||
if (startupHttps) {
|
||||
@ -165,7 +161,7 @@ httpsPromise.then(function(startupHttps) {
|
||||
if (settings.httpsRefreshInterval) {
|
||||
if (typeof settings.https === "function") {
|
||||
if (server.setSecureContext) {
|
||||
console.log("Refreshing https settings every " + parseInt(settings.httpsRefreshInterval) + " seconds.");
|
||||
delayedLogItems.push({type:"info", id:"server.https.refresh-interval", params:{interval:parseInt(settings.httpsRefreshInterval)}});
|
||||
setInterval(function () {
|
||||
try {
|
||||
// Get the result of the function, because createServer doesn't accept functions as input
|
||||
@ -174,27 +170,27 @@ httpsPromise.then(function(startupHttps) {
|
||||
httpsPromise.then(function(refreshedHttps) {
|
||||
// Use the refreshed https settings
|
||||
if (!refreshedHttps.key || !refreshedHttps.cert) {
|
||||
console.log("Cannot refresh the https settings when the https property function doesn't return a 'key' and 'cert'.");
|
||||
RED.log.warn(RED.log._("server.https.missing-fields"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Only update the credentials in the server when key or cert has changed
|
||||
if(!server.key || !server.cert || !server.key.equals(refreshedHttps.key) || !server.cert.equals(refreshedHttps.cert)) {
|
||||
server.setSecureContext(refreshedHttps);
|
||||
console.log("The https settings have been refreshed.");
|
||||
RED.log.info(RED.log._("server.https.settings-refreshed"));
|
||||
}
|
||||
}).catch(function(err) {
|
||||
console.log("Failed to apply the refreshed https settings: " + err);
|
||||
RED.log.error(RED.log._("server.https.apply-failed",{message:err}));
|
||||
});
|
||||
} catch(err) {
|
||||
console.log("Failed to get the refreshed https settings: " + err);
|
||||
RED.log.error(RED.log._("server.https.get-failed",{message:err}));
|
||||
}
|
||||
}, parseInt(settings.httpsRefreshInterval)*1000);
|
||||
} else {
|
||||
console.log("Cannot refresh the https settings automatically, because NodeJs version 11 or above is required.");
|
||||
delayedLogItems.push({type:"warn", id:"server.https.nodejs-version", params:{}});
|
||||
}
|
||||
} else {
|
||||
console.log("Cannot refresh the https settings automatically (at httpsRefreshInterval), because the https property needs to be a function.");
|
||||
delayedLogItems.push({type:"warn", id:"server.https.function-required", params:{}});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -365,6 +361,12 @@ httpsPromise.then(function(startupHttps) {
|
||||
}
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
// Log all the delayed messages, since they can be translated at this point
|
||||
delayedLogItems.forEach(function (delayedLogItem, index) {
|
||||
RED.log[delayedLogItem.type](RED.log._(delayedLogItem.id, delayedLogItem.params));
|
||||
});
|
||||
|
||||
server.listen(settings.uiPort,settings.uiHost,function() {
|
||||
if (settings.httpAdminRoot === false) {
|
||||
RED.log.info(RED.log._("server.admin-ui-disabled"));
|
||||
@ -402,4 +404,4 @@ httpsPromise.then(function(startupHttps) {
|
||||
});
|
||||
}).catch(function(err) {
|
||||
console.log("Failed to get https settings: " + err);
|
||||
});;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user