mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00: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 = settings.editorTheme.projects || {};
|
||||||
settings.editorTheme.projects.enabled = !/^false$/i.test(process.env.NODE_RED_ENABLE_PROJECTS);
|
settings.editorTheme.projects.enabled = !/^false$/i.test(process.env.NODE_RED_ENABLE_PROJECTS);
|
||||||
}
|
}
|
||||||
|
debugger;
|
||||||
|
|
||||||
var httpsPromise;
|
// Delay logging of (translated) messages until the RED object has been initialized
|
||||||
if (settings.https) {
|
var delayedLogItems = [];
|
||||||
var startupHttps = settings.https;
|
|
||||||
|
|
||||||
if (typeof startupHttps === "function") {
|
var startupHttps = settings.https;
|
||||||
// Get the result of the function, because createServer doesn't accept functions as input
|
if (typeof startupHttps === "function") {
|
||||||
startupHttps = startupHttps();
|
// Get the result of the function, because createServer doesn't accept functions as input
|
||||||
}
|
startupHttps = startupHttps();
|
||||||
httpsPromise = Promise.resolve(startupHttps);
|
}
|
||||||
}
|
var httpsPromise = Promise.resolve(startupHttps);
|
||||||
else {
|
|
||||||
// No https is enable - wrap null
|
|
||||||
httpsPromise = Promise.resolve(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
httpsPromise.then(function(startupHttps) {
|
httpsPromise.then(function(startupHttps) {
|
||||||
if (startupHttps) {
|
if (startupHttps) {
|
||||||
@ -165,7 +161,7 @@ httpsPromise.then(function(startupHttps) {
|
|||||||
if (settings.httpsRefreshInterval) {
|
if (settings.httpsRefreshInterval) {
|
||||||
if (typeof settings.https === "function") {
|
if (typeof settings.https === "function") {
|
||||||
if (server.setSecureContext) {
|
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 () {
|
setInterval(function () {
|
||||||
try {
|
try {
|
||||||
// Get the result of the function, because createServer doesn't accept functions as input
|
// 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) {
|
httpsPromise.then(function(refreshedHttps) {
|
||||||
// Use the refreshed https settings
|
// Use the refreshed https settings
|
||||||
if (!refreshedHttps.key || !refreshedHttps.cert) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only update the credentials in the server when key or cert has changed
|
// 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)) {
|
if(!server.key || !server.cert || !server.key.equals(refreshedHttps.key) || !server.cert.equals(refreshedHttps.cert)) {
|
||||||
server.setSecureContext(refreshedHttps);
|
server.setSecureContext(refreshedHttps);
|
||||||
console.log("The https settings have been refreshed.");
|
RED.log.info(RED.log._("server.https.settings-refreshed"));
|
||||||
}
|
}
|
||||||
}).catch(function(err) {
|
}).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) {
|
} 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);
|
}, parseInt(settings.httpsRefreshInterval)*1000);
|
||||||
} else {
|
} 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 {
|
} 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 {
|
} else {
|
||||||
@ -365,6 +361,12 @@ httpsPromise.then(function(startupHttps) {
|
|||||||
}
|
}
|
||||||
process.exit(1);
|
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() {
|
server.listen(settings.uiPort,settings.uiHost,function() {
|
||||||
if (settings.httpAdminRoot === false) {
|
if (settings.httpAdminRoot === false) {
|
||||||
RED.log.info(RED.log._("server.admin-ui-disabled"));
|
RED.log.info(RED.log._("server.admin-ui-disabled"));
|
||||||
@ -402,4 +404,4 @@ httpsPromise.then(function(startupHttps) {
|
|||||||
});
|
});
|
||||||
}).catch(function(err) {
|
}).catch(function(err) {
|
||||||
console.log("Failed to get https settings: " + err);
|
console.log("Failed to get https settings: " + err);
|
||||||
});;
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user