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}); }); }