sudo: use debug() to have provide timestamped logs
the exception is when sudo calls backupupload.js which already has timestamped output because it uses node an alternative idea is to maybe not use this flag at all and always parse the output. this is a bit complicated since we have to look for a timestamp in a stream.
This commit is contained in:
+4
-4
@@ -98,6 +98,8 @@ function sudo(tag, args, options, callback) {
|
||||
|
||||
callback = once(callback); // exit may or may not be called after an 'error'
|
||||
|
||||
const logFunc = options.outputHasTimestamps ? process.stdoud.write : debug;
|
||||
|
||||
if (options.ipc) {
|
||||
sudoArgs.push('--close-from=4'); // keep the ipc open. requires closefrom_override in sudoers file
|
||||
options.stdio = ['pipe', 'pipe', 'pipe', 'ipc'];
|
||||
@@ -111,11 +113,9 @@ function sudo(tag, args, options, callback) {
|
||||
|
||||
cp.stdout.on('data', (data) => {
|
||||
if (options.captureStdout) stdoutResult += data.toString('utf8');
|
||||
if (!options.quiet) 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.quiet) logFunc(data.toString('utf8'));
|
||||
});
|
||||
cp.stderr.on('data', (data) => logFunc(data.toString('utf8')));
|
||||
|
||||
cp.on('exit', function (code, signal) {
|
||||
if (code === 0) return callback(null, options.captureStdout ? stdoutResult : null);
|
||||
|
||||
Reference in New Issue
Block a user