2019-01-13 17:55:25 -05:00
|
|
|
var fs = require('fs');
|
|
|
|
var common = require('../common');
|
|
|
|
|
2019-07-27 14:20:17 -04:00
|
|
|
exports.info = (msgJSON, selNode = common.selectedNode) => {
|
|
|
|
const msgStr = '\r\nINFO: ' + msgJSON.fileName + ' => ' + msgJSON.msg;
|
|
|
|
if (msgJSON.fileName !== 'Config Setup Variable') {
|
2020-01-29 18:36:28 -05:00
|
|
|
console.log(msgStr);
|
2019-02-13 21:31:26 -05:00
|
|
|
}
|
2019-12-11 19:58:20 -05:00
|
|
|
if(selNode && selNode.enable_logging) {
|
2019-04-05 22:52:00 -04:00
|
|
|
fs.appendFile(selNode.log_file, msgStr, function(err) {
|
|
|
|
if (err) {
|
|
|
|
return ({ error: 'Updating Log Failed!' });
|
|
|
|
} else {
|
|
|
|
return ({ message: 'Log Updated Successfully' });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-01-13 17:55:25 -05:00
|
|
|
}
|
|
|
|
|
2019-07-27 14:20:17 -04:00
|
|
|
exports.error = (msgJSON, selNode = common.selectedNode) => {
|
|
|
|
const msgStr = '\r\nERROR: ' + msgJSON.fileName + '(' + msgJSON.lineNum + ') => ' + msgJSON.msg;
|
2020-01-29 18:36:28 -05:00
|
|
|
console.error(msgStr);
|
2019-12-11 19:58:20 -05:00
|
|
|
if(selNode && selNode.enable_logging) {
|
2019-04-05 22:52:00 -04:00
|
|
|
fs.appendFile(selNode.log_file, msgStr, function(err) {
|
|
|
|
if (err) {
|
|
|
|
return ({ error: 'Updating Log Failed!' });
|
|
|
|
} else {
|
|
|
|
return ({ message: 'Log Updated Successfully' });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-07-27 14:20:17 -04:00
|
|
|
}
|