From 27b3b0ecd24faee7f511dd7fbae1af13cbd59cf5 Mon Sep 17 00:00:00 2001 From: muxator Date: Mon, 27 Aug 2018 01:29:37 +0200 Subject: [PATCH] logs: on the server, use template literals when possible It's just synctactic sugar, but it is always better than executing string concatenations in one's mind. Do not do this with files in src/static, because we want to keep IE 11 compatibility. --- src/node/db/SessionManager.js | 2 +- src/node/hooks/express.js | 14 +++++++------- src/node/utils/Abiword.js | 4 ++-- src/node/utils/LibreOffice.js | 2 +- src/node/utils/Settings.js | 8 ++++---- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/node/db/SessionManager.js b/src/node/db/SessionManager.js index f8000e47..518c70c7 100644 --- a/src/node/db/SessionManager.js +++ b/src/node/db/SessionManager.js @@ -353,7 +353,7 @@ function listSessionsWithDBKey (dbkey, callback) { if (err == "apierror: sessionID does not exist") { - console.warn("Found bad session " + sessionID + " in " + dbkey + "."); + console.warn(`Found bad session ${sessionID} in ${dbkey}`); } else if(ERR(err, callback)) { diff --git a/src/node/hooks/express.js b/src/node/hooks/express.js index 48dcf56c..e7b37380 100644 --- a/src/node/hooks/express.js +++ b/src/node/hooks/express.js @@ -12,15 +12,15 @@ var serverName; exports.createServer = function () { console.log("Report bugs at https://github.com/ether/etherpad-lite/issues") - serverName = "Etherpad " + settings.getGitCommit() + " (http://etherpad.org)"; + serverName = `Etherpad ${settings.getGitCommit()} (http://etherpad.org)`; - console.log("Your Etherpad version is " + settings.getEpVersion() + " (" + settings.getGitCommit() + ")"); + console.log(`Your Etherpad version is ${settings.getEpVersion()} (${settings.getGitCommit()})`); exports.restartServer(); - console.log("You can access your Etherpad instance at http://" + settings.ip + ":" + settings.port + "/"); + console.log(`You can access your Etherpad instance at http://${settings.ip}:${settings.port}/`); if(!_.isEmpty(settings.users)){ - console.log("The plugin admin page is at http://" + settings.ip + ":" + settings.port + "/admin/plugins"); + console.log(`The plugin admin page is at http://${settings.ip}:${settings.port}/admin/plugins`); } else{ console.warn("Admin username and password not set in settings.json. To access admin please uncomment and edit 'users' in settings.json"); @@ -42,9 +42,9 @@ exports.restartServer = function () { if (settings.ssl) { - console.log( "SSL -- enabled"); - console.log( "SSL -- server key file: " + settings.ssl.key ); - console.log( "SSL -- Certificate Authority's certificate file: " + settings.ssl.cert ); + console.log("SSL -- enabled"); + console.log(`SSL -- server key file: ${settings.ssl.key}`); + console.log(`SSL -- Certificate Authority's certificate file: ${settings.ssl.cert}`); var options = { key: fs.readFileSync( settings.ssl.key ), diff --git a/src/node/utils/Abiword.js b/src/node/utils/Abiword.js index 1d9ac5d3..2aae5a8a 100644 --- a/src/node/utils/Abiword.js +++ b/src/node/utils/Abiword.js @@ -52,7 +52,7 @@ if(os.type().indexOf("Windows") > -1) abiword.on('exit', function (code) { if(code != 0) { - return callback("Abiword died with exit code " + code); + return callback(`Abiword died with exit code ${code}`); } if(stdoutBuffer != "") @@ -91,7 +91,7 @@ else abiword.on('exit', function (code) { spawnAbiword(); - stdoutCallback("Abiword died with exit code " + code); + stdoutCallback(`Abiword died with exit code ${code}`); }); //delegate the processing of stdout to a other function diff --git a/src/node/utils/LibreOffice.js b/src/node/utils/LibreOffice.js index 9127d18d..6f049d22 100644 --- a/src/node/utils/LibreOffice.js +++ b/src/node/utils/LibreOffice.js @@ -84,7 +84,7 @@ function doConvertTask(task, callback) { // Throw an exception if libreoffice failed soffice.on('exit', function(code) { if (code != 0) { - return callback("LibreOffice died with exit code " + code + " and message: " + stdoutBuffer); + return callback(`LibreOffice died with exit code ${code} and message: ${stdoutBuffer}`); } callback(); diff --git a/src/node/utils/Settings.js b/src/node/utils/Settings.js index 648ecbbb..508e6148 100644 --- a/src/node/utils/Settings.js +++ b/src/node/utils/Settings.js @@ -396,7 +396,7 @@ exports.reloadSettings = function reloadSettings() { //test if the setting start with a lowercase character if(i.charAt(0).search("[a-z]") !== 0) { - console.warn("Settings should start with a lowercase character: '" + i + "'"); + console.warn(`Settings should start with a lowercase character: '${i}'`); } //we know this setting, so we overwrite it @@ -412,7 +412,7 @@ exports.reloadSettings = function reloadSettings() { //this setting is unkown, output a warning and throw it away else { - console.warn("Unknown Setting: '" + i + "'. This setting doesn't exist or it was removed"); + console.warn(`Unknown Setting: '${i}'. This setting doesn't exist or it was removed`); } } @@ -422,7 +422,7 @@ exports.reloadSettings = function reloadSettings() { //test if the setting start with a lowercase character if(i.charAt(0).search("[a-z]") !== 0) { - console.warn("Settings should start with a lowercase character: '" + i + "'"); + console.warn(`Settings should start with a lowercase character: '${i}'`); } //we know this setting, so we overwrite it @@ -438,7 +438,7 @@ exports.reloadSettings = function reloadSettings() { //this setting is unkown, output a warning and throw it away else { - console.warn("Unknown Setting: '" + i + "'. This setting doesn't exist or it was removed"); + console.warn(`Unknown Setting: '${i}'. This setting doesn't exist or it was removed`); } }