summaryrefslogtreecommitdiff
path: root/src/node/utils
diff options
context:
space:
mode:
authorSimon Gaeremynck <gaeremyncks@gmail.com>2015-05-18 17:43:46 +0100
committerSimon Gaeremynck <gaeremyncks@gmail.com>2015-05-18 17:43:46 +0100
commit7fe99cccad64707a46d3120d6a18f2e6d0724b90 (patch)
tree7c9586f26e2fa3e3aebacc2c9595a668b2b80729 /src/node/utils
parent786b43efc893ceb3fcf3d1d6acb9f46fc4b5426f (diff)
downloadetherpad-lite-7fe99cccad64707a46d3120d6a18f2e6d0724b90.zip
Using log4js in TidyHtml
Diffstat (limited to 'src/node/utils')
-rw-r--r--src/node/utils/TidyHtml.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/node/utils/TidyHtml.js b/src/node/utils/TidyHtml.js
index 13dc2ece..5d4e6ed7 100644
--- a/src/node/utils/TidyHtml.js
+++ b/src/node/utils/TidyHtml.js
@@ -2,18 +2,23 @@
* Tidy up the HTML in a given file
*/
-var settings = require("./Settings");
+var log4js = require('log4js');
+var settings = require('./Settings');
var spawn = require('child_process').spawn;
exports.tidy = function(srcFile, callback) {
+ var logger = log4js.getLogger('TidyHtml');
+
// Don't do anything if Tidy hasn't been enabled
if (!settings.tidyHtml) {
+ logger.debug('tidyHtml has not been configured yet, ignoring tidy request');
return callback(null);
}
var errMessage = '';
// Spawn a new tidy instance that cleans up the file inline
+ logger.debug('Tidying ' + srcFile);
var tidy = spawn(settings.tidyHtml, ['-modify', srcFile]);
// Keep track of any error messages
@@ -26,9 +31,10 @@ exports.tidy = function(srcFile, callback) {
// Tidy returns a 0 when no errors occur and a 1 exit code when
// the file could be tidied but a few warnings were generated
if (code === 0 || code === 1) {
+ logger.debug('Tidied ' + srcFile + ' successfully');
return callback(null);
} else {
- console.error(errMessage);
+ logger.error('Failed to tidy ' + srcFile + '\n' + errMessage);
return callback('Tidy died with exit code ' + code);
}
});