diff --git a/lib/worker.js b/lib/worker.js index 835c7d7..0e48d42 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -215,6 +215,13 @@ FiveBeansWorker.prototype.doWork = function doWork(handler, jobID, jobdata) var start = new Date().getTime(); this.currentJob = jobID; this.currentHandler = handler; + var handlerName = (function(handler) { + if (handler.constructor && handler.constructor.name) { + return handler.constructor.name; + } + + return handler.type; + })(handler); try { @@ -222,7 +229,7 @@ FiveBeansWorker.prototype.doWork = function doWork(handler, jobID, jobdata) { var elapsed = new Date().getTime() - start; - self.emit('job.handled', { id: jobID, type: handler.type, elapsed: elapsed, action: action }); + self.emit('job.handled', { id: jobID, type: handlerName, elapsed: elapsed, action: action }, jobdata); switch (action) { @@ -246,7 +253,7 @@ FiveBeansWorker.prototype.doWork = function doWork(handler, jobID, jobdata) } catch (e) { - self.emitWarning({ message: 'exception in job handler', id: jobID, handler: handler.type, error: e }); + self.emitWarning({ message: 'exception in job handler', id: jobID, handler: handlerName, error: e }); self.buryAndMoveOn(jobID); } };