create debugging output wrapper
This commit is contained in:
@@ -24,6 +24,8 @@ export default class Job extends events.EventEmitter {
|
|||||||
this.maxAttempts = options.max_attempts || 3;
|
this.maxAttempts = options.max_attempts || 3;
|
||||||
this.priority = Math.max(Math.min(options.priority || 10, 20), -20);
|
this.priority = Math.max(Math.min(options.priority || 10, 20), -20);
|
||||||
|
|
||||||
|
this.debug = (...msg) => debug(...msg, `id: ${this.id}`);
|
||||||
|
|
||||||
this.ready = createIndex(client, index)
|
this.ready = createIndex(client, index)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return this.client.index({
|
return this.client.index({
|
||||||
@@ -46,11 +48,12 @@ export default class Job extends events.EventEmitter {
|
|||||||
type: doc._type,
|
type: doc._type,
|
||||||
version: doc._version,
|
version: doc._version,
|
||||||
};
|
};
|
||||||
debug('Job created', this.document);
|
this.debug('Job created');
|
||||||
|
this.emit('created', this.document);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
debug('Job creation failed', err);
|
this.debug('Job creation failed', err);
|
||||||
this.emit('error', err);
|
this.emit('error', err);
|
||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user