Use correct logger inside child emitters

This commit is contained in:
Annika Backstrom 2017-04-09 15:24:03 -04:00
parent 2ec67288e4
commit 1ad4be4bff
1 changed files with 5 additions and 3 deletions

View File

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