mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
Using log4js in TidyHtml
This commit is contained in:
parent
786b43efc8
commit
7fe99cccad
1 changed files with 8 additions and 2 deletions
|
@ -2,18 +2,23 @@
|
||||||
* Tidy up the HTML in a given file
|
* 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;
|
var spawn = require('child_process').spawn;
|
||||||
|
|
||||||
exports.tidy = function(srcFile, callback) {
|
exports.tidy = function(srcFile, callback) {
|
||||||
|
var logger = log4js.getLogger('TidyHtml');
|
||||||
|
|
||||||
// Don't do anything if Tidy hasn't been enabled
|
// Don't do anything if Tidy hasn't been enabled
|
||||||
if (!settings.tidyHtml) {
|
if (!settings.tidyHtml) {
|
||||||
|
logger.debug('tidyHtml has not been configured yet, ignoring tidy request');
|
||||||
return callback(null);
|
return callback(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
var errMessage = '';
|
var errMessage = '';
|
||||||
|
|
||||||
// Spawn a new tidy instance that cleans up the file inline
|
// Spawn a new tidy instance that cleans up the file inline
|
||||||
|
logger.debug('Tidying ' + srcFile);
|
||||||
var tidy = spawn(settings.tidyHtml, ['-modify', srcFile]);
|
var tidy = spawn(settings.tidyHtml, ['-modify', srcFile]);
|
||||||
|
|
||||||
// Keep track of any error messages
|
// 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
|
// 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
|
// the file could be tidied but a few warnings were generated
|
||||||
if (code === 0 || code === 1) {
|
if (code === 0 || code === 1) {
|
||||||
|
logger.debug('Tidied ' + srcFile + ' successfully');
|
||||||
return callback(null);
|
return callback(null);
|
||||||
} else {
|
} else {
|
||||||
console.error(errMessage);
|
logger.error('Failed to tidy ' + srcFile + '\n' + errMessage);
|
||||||
return callback('Tidy died with exit code ' + code);
|
return callback('Tidy died with exit code ' + code);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue