handle errors in log stream

This commit is contained in:
Girish Ramakrishnan
2017-10-11 12:41:40 -07:00
parent 5694e676bd
commit 28ce5f41e3
3 changed files with 13 additions and 6 deletions

View File

@@ -42,10 +42,9 @@ function exec(tag, file, args, options, callback) {
debug(tag + ' execFile: %s', file); // do not dump args as it might have sensitive info
var cp = child_process.spawn(file, args, options);
if (options.logFile) {
var logFile = fs.createWriteStream(options.logFile, { flags: 'a' });
cp.stdout.pipe(logFile);
cp.stderr.pipe(logFile);
if (options.logStream) {
cp.stdout.pipe(options.logStream);
cp.stderr.pipe(options.logStream);
} else {
cp.stdout.on('data', function (data) {
debug(tag + ' (stdout): %s', data.toString('utf8'));