make taskworker console.* log to file and not stdout

this is similar to code in box.js
This commit is contained in:
Girish Ramakrishnan
2021-05-13 22:11:23 -07:00
parent e6edc4e999
commit f927b9b5b2
2 changed files with 4 additions and 9 deletions

View File

@@ -43,15 +43,10 @@ const taskId = process.argv[2];
const logFile = process.argv[3];
function setupLogging(callback) {
fs.open(logFile, 'a', function (error, fd) {
if (error) return callback(error);
const logfileStream = fs.createWriteStream(logFile, { flags:'a' });
process.stdout.write = process.stderr.write = logfileStream.write.bind(logfileStream);
require('debug').log = function (...args) {
fs.appendFileSync(fd, util.format(...args) + '\n');
};
callback();
});
callback();
}
// Main process starts here