From 1ad4be4bff18af95019069a580d3410b723c2d18 Mon Sep 17 00:00:00 2001 From: Annika Backstrom Date: Sun, 9 Apr 2017 15:24:03 -0400 Subject: [PATCH] Use correct logger inside child emitters --- jukebox/child-process.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jukebox/child-process.js b/jukebox/child-process.js index 3c0f23d..b395af1 100644 --- a/jukebox/child-process.js +++ b/jukebox/child-process.js @@ -10,6 +10,8 @@ module.exports.ChildProcessEmitter = class ChildProcessEmitter extends EventEmit constructor(command, logger) { super(); + var emitter = this; + this.logger = logger; this.stderrFilters = []; @@ -19,11 +21,11 @@ module.exports.ChildProcessEmitter = class ChildProcessEmitter extends EventEmit this.childProcess = spawn(cmd, args); this.childProcess.on('error', function(err) { - this.logger.error("process error", { class: this.constructor.name, name: name, err: String(err).trim() }); + emitter.logger.error("process error", { class: emitter.constructor.name, err: String(err).trim() }); }); this.childProcess.on('close', function(code, signal) { - this.logger.debug("process closed", { class: this.constructor.name, name: name, code: code, signal: signal }); + emitter.logger.debug("process closed", { class: emitter.constructor.name, code: code, signal: signal }); }); this.childProcess.stdout.on('data', (data) => { @@ -41,7 +43,7 @@ module.exports.ChildProcessEmitter = class ChildProcessEmitter extends EventEmit if (filtered) { return; } - this.logger.error('process stderr', { class: this.constructor.name, stderr: line}); + emitter.logger.error('process stderr', { class: emitter.constructor.name, stderr: line}); }); }