refactor(GUI): increase writer proxy logging (#576)

We were facing quite some issues that involved debugging the writer child
process, which proved to be a very difficult task given the lack of information
we're exposing to the parent.

This is an attempt to improve that situation.

Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
This commit is contained in:
Juan Cruz Viotti 2016-07-18 10:18:15 -04:00 committed by GitHub
parent 1308177d54
commit b965b5d835
2 changed files with 17 additions and 0 deletions

View File

@ -77,6 +77,10 @@ exports.write = (image, drive, options) => {
env: process.env
});
child.stdout.on('data', (data) => {
console.info(`WRITER: ${data.toString()}`);
});
child.stderr.on('data', (data) => {
emitter.emit('error', new Error(data.toString()));
});

View File

@ -46,6 +46,7 @@ return isElevated().then((elevated) => {
const logFile = process.env[CONSTANTS.TEMPORARY_LOG_FILE_ENVIRONMENT_VARIABLE];
if (process.send) {
console.log(`Tailing ${logFile}`);
// Sadly, `fs.createReadStream()` won't work since
// the stream that function returns gets closed
@ -77,6 +78,7 @@ return isElevated().then((elevated) => {
}
if (!elevated) {
console.log('Attempting to elevate');
if (os.platform() === 'win32') {
const elevator = Bluebird.promisifyAll(require('elevator'));
@ -192,8 +194,19 @@ return isElevated().then((elevated) => {
});
}
console.log('Re-spawning with elevation');
return new Bluebird((resolve, reject) => {
const child = childProcess.spawn(EXECUTABLE, ETCHER_ARGUMENTS);
child.stdout.on('data', (data) => {
console.log(data.toString());
});
child.stderr.on('data', (data) => {
console.error(data.toString());
});
child.on('error', reject);
child.on('close', resolve);
}).then((exitCode) => {