From 51bb2d2bc2b8d9dece4f00fd49f5e3ac42867b01 Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Thu, 25 Jul 2024 10:21:57 +0200 Subject: [PATCH] Add option to not log shell subprocess stdout+stderr When tailing the box log file this leads to logline recursion --- src/logs.js | 2 +- src/shell.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/logs.js b/src/logs.js index 33a579dde..aa226132c 100644 --- a/src/logs.js +++ b/src/logs.js @@ -60,7 +60,7 @@ function tail(filePaths, options) { const args = [ LOGTAIL_CMD, '--lines=' + lines ]; if (options.follow) args.push('--follow'); - return shell.sudo('tail', args.concat(filePaths), { streamStdout: true }, () => {}); + return shell.sudo('tail', args.concat(filePaths), { streamStdout: true, dropStdout: true, dropStdErr: true }, () => {}); } function journalctl(unit, options) { diff --git a/src/shell.js b/src/shell.js index c1a1ac0cd..47cf612d8 100644 --- a/src/shell.js +++ b/src/shell.js @@ -111,10 +111,10 @@ function sudo(tag, args, options, callback) { cp.stdout.on('data', (data) => { if (options.captureStdout) stdoutResult += data.toString('utf8'); - process.stdout.write(data); // do not use debug to avoid double timestamps when calling backupupload.js + if (!options.dropStdout) process.stdout.write(data); // do not use debug to avoid double timestamps when calling backupupload.js }); cp.stderr.on('data', (data) => { - process.stderr.write(data); // do not use debug to avoid double timestamps when calling backupupload.js + if (!options.dropStderr) process.stderr.write(data); // do not use debug to avoid double timestamps when calling backupupload.js }); cp.on('exit', function (code, signal) {