2
0
mirror of https://github.com/Ride-The-Lightning/RTL synced 2024-11-17 15:29:30 +00:00
RTL/controllers/logger.js

33 lines
998 B
JavaScript
Raw Normal View History

2019-01-13 22:55:25 +00:00
var fs = require('fs');
var common = require('../common');
2019-07-27 18:20:17 +00:00
exports.info = (msgJSON, selNode = common.selectedNode) => {
const msgStr = '\r\nINFO: ' + msgJSON.fileName + ' => ' + msgJSON.msg;
if (msgJSON.fileName !== 'Config Setup Variable') {
console.log(msgStr);
}
if(selNode && selNode.enable_logging) {
2019-04-06 02:52:00 +00: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 22:55:25 +00:00
}
2019-07-27 18:20:17 +00:00
exports.error = (msgJSON, selNode = common.selectedNode) => {
const msgStr = '\r\nERROR: ' + msgJSON.fileName + '(' + msgJSON.lineNum + ') => ' + msgJSON.msg;
console.error(msgStr);
if(selNode && selNode.enable_logging) {
2019-04-06 02:52:00 +00: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 18:20:17 +00:00
}