mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-21 17:17:58 +00:00
improve log messages
This commit is contained in:
@@ -63,14 +63,16 @@ class Cognigy extends Task {
|
||||
async _enqueueTask(task) {
|
||||
let resolver;
|
||||
let rejector;
|
||||
|
||||
const boundTask = task.bind(this);
|
||||
const taskPromise = new Promise(async(resolve, reject) => {
|
||||
resolver = resolve;
|
||||
rejector = reject;
|
||||
});
|
||||
this.taskQueue.push(async(cb) => {
|
||||
this.logger.info('EXECUTING SAY TASK');
|
||||
this.logger.debug('executing say task from queue');
|
||||
try {
|
||||
const result = await task();
|
||||
const result = await boundTask();
|
||||
resolver(result);
|
||||
cb(result);
|
||||
} catch (err) {
|
||||
@@ -78,7 +80,7 @@ class Cognigy extends Task {
|
||||
rejector(err);
|
||||
cb(err);
|
||||
}
|
||||
this.logger.info('SAY TASK EXECUTED');
|
||||
this.logger.debug('say task executed from queue');
|
||||
});
|
||||
this.taskQueue.lastPromise = taskPromise;
|
||||
return taskPromise;
|
||||
@@ -256,11 +258,11 @@ class Cognigy extends Task {
|
||||
const text = parseBotText(evt);
|
||||
if (evt.data) this.config.update(evt.data);
|
||||
if (text) {
|
||||
this._enqueueTask((async() => {
|
||||
this._enqueueTask(async() => {
|
||||
this.logger.info({text}, 'received text');
|
||||
const sayTask = this._makeSayTask(text);
|
||||
await sayTask.exec(cs, ep, this);
|
||||
}).bind(this));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -268,7 +270,7 @@ class Cognigy extends Task {
|
||||
try {
|
||||
switch (evt.data.type) {
|
||||
case 'hangup':
|
||||
this._enqueueTask((async() => {
|
||||
this._enqueueTask(async() => {
|
||||
this.performAction({cognigyResult: 'hangup Succeeded'});
|
||||
this.reportedFinalAction = true;
|
||||
cs.replaceApplication([{hangup: {
|
||||
@@ -277,18 +279,18 @@ class Cognigy extends Task {
|
||||
}
|
||||
}}]);
|
||||
this.taskQueue.end();
|
||||
}).bind(this));
|
||||
});
|
||||
|
||||
return;
|
||||
case 'refer':
|
||||
this._enqueueTask((async() => {
|
||||
this._enqueueTask(async() => {
|
||||
this.performAction({cognigyResult: 'refer succeeded'});
|
||||
this.reportedFinalAction = true;
|
||||
cs.replaceApplication([{'sip:refer': {
|
||||
referTo: evt.data.number,
|
||||
referredBy: 'cognigy'
|
||||
}}]);
|
||||
}).bind(this));
|
||||
});
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user