From 6556ab4e0523e6be9f89f80f9b2d075338841a0b Mon Sep 17 00:00:00 2001 From: johnjbarton Date: Fri, 12 Apr 2019 09:40:00 -0700 Subject: [PATCH] fix(launcher): Log state transitions in debug (#3294) See #3290 --- lib/launchers/base.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/launchers/base.js b/lib/launchers/base.js index bbb8de70f..b8349ce3a 100644 --- a/lib/launchers/base.js +++ b/lib/launchers/base.js @@ -5,12 +5,12 @@ const Promise = require('bluebird') const log = require('../logger').create('launcher') const helper = require('../helper') -const BEING_CAPTURED = 1 -const CAPTURED = 2 -const BEING_KILLED = 3 -const FINISHED = 4 -const RESTARTING = 5 -const BEING_FORCE_KILLED = 6 +const BEING_CAPTURED = 'BEING_CAPTURED' +const CAPTURED = 'CAPTURED' +const BEING_KILLED = 'BEING_KILLED' +const FINISHED = 'FINISHED' +const RESTARTING = 'RESTARTING' +const BEING_FORCE_KILLED = 'BEING_FORCE_KILLED' /** * Base launcher that any custom launcher extends. @@ -29,7 +29,17 @@ function BaseLauncher (id, emitter) { this.emitAsync = KarmaEventEmitter.prototype.emitAsync.bind(this) this.id = id - this.state = null + this._state = null + Object.defineProperty(this, 'state', { + get: () => { + return this._state + }, + set: (toState) => { + log.debug(`${this._state} -> ${toState}`) + this._state = toState + } + }) + this.error = null let killingPromise