From 8cf107c34c9e10bff3456e8bc9e3a755c2f60bbd Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Fri, 28 Feb 2020 10:25:43 -0500 Subject: [PATCH] logging --- lib/middleware.js | 5 ++++- lib/session/call-session.js | 2 +- lib/tasks/make_task.js | 2 +- lib/tasks/tag.js | 2 +- lib/utils/normalize-jamones.js | 2 -- lib/utils/requestor.js | 2 +- package.json | 2 +- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/middleware.js b/lib/middleware.js index 9c7f47d5..f59c4059 100644 --- a/lib/middleware.js +++ b/lib/middleware.js @@ -83,7 +83,10 @@ module.exports = function(srf, logger) { else app.notifier = {request: () => {}}; req.locals.application = app; - logger.debug(app, `retrieved application for ${req.locals.calledNumber}`); + const obj = Object.assign({}, app); + delete obj.requestor; + delete obj.notifier; + logger.info({app: obj}, `retrieved application for incoming call to ${req.locals.calledNumber}`); req.locals.callInfo = new CallInfo({req, app, direction: CallDirection.Inbound}); next(); } catch (err) { diff --git a/lib/session/call-session.js b/lib/session/call-session.js index d378c932..d35a492c 100644 --- a/lib/session/call-session.js +++ b/lib/session/call-session.js @@ -555,7 +555,7 @@ class CallSession extends Emitter { } // update calls db - this.logger.debug(`updating redis with ${JSON.stringify(this.callInfo)}`); + //this.logger.debug(`updating redis with ${JSON.stringify(this.callInfo)}`); this.updateCallStatus(Object.assign({}, this.callInfo), this.serviceUrl) .catch((err) => this.logger.error(err, 'redis error')); } diff --git a/lib/tasks/make_task.js b/lib/tasks/make_task.js index d8b2633d..6e583d5b 100644 --- a/lib/tasks/make_task.js +++ b/lib/tasks/make_task.js @@ -9,7 +9,7 @@ function makeTask(logger, obj, parent) { } const name = keys[0]; const data = obj[name]; - logger.debug(data, `makeTask: ${name}`); + //logger.debug(data, `makeTask: ${name}`); if (typeof data !== 'object') { throw errBadInstruction; } diff --git a/lib/tasks/tag.js b/lib/tasks/tag.js index 7b75f666..c9d353ad 100644 --- a/lib/tasks/tag.js +++ b/lib/tasks/tag.js @@ -12,7 +12,7 @@ class TaskTag extends Task { async exec(cs) { super.exec(cs); cs.callInfo.customerData = this.data; - this.logger.debug({callInfo: cs.callInfo.toJSON()}, 'TaskTag:exec set customer data in callInfo'); + //this.logger.debug({callInfo: cs.callInfo.toJSON()}, 'TaskTag:exec set customer data in callInfo'); } } diff --git a/lib/utils/normalize-jamones.js b/lib/utils/normalize-jamones.js index 015d101e..74c847cf 100644 --- a/lib/utils/normalize-jamones.js +++ b/lib/utils/normalize-jamones.js @@ -1,5 +1,4 @@ function normalizeJambones(logger, obj) { - logger.debug(`normalizeJambones: ${JSON.stringify(obj)}`); if (!Array.isArray(obj)) throw new Error('malformed jambonz payload: must be array'); const document = []; for (const tdata of obj) { @@ -17,7 +16,6 @@ function normalizeJambones(logger, obj) { } else if (Object.keys(tdata).length === 1) { // {'say': {..}} - logger.debug(`pushing ${JSON.stringify(tdata)}`); document.push(tdata); } else { diff --git a/lib/utils/requestor.js b/lib/utils/requestor.js index 9e70d7b5..111911f2 100644 --- a/lib/utils/requestor.js +++ b/lib/utils/requestor.js @@ -86,12 +86,12 @@ class Requestor { const diff = process.hrtime(startAt); const time = diff[0] * 1e3 + diff[1] * 1e-6; const rtt = time.toFixed(0); - this.logger.debug(`Requestor:request ${method} ${url} succeeded in ${rtt}ms`); if (buf) this.stats.histogram('app.hook.response_time', rtt, ['hook_type:app']); if (buf && buf.toString().length > 0) { try { const json = JSON.parse(buf.toString()); + this.logger.info({response: json}, `Requestor:request ${method} ${url} succeeded in ${rtt}ms`); return json; } catch (err) { diff --git a/package.json b/package.json index 28daf07b..72f41ac5 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "ip": "^1.1.5", "cidr-matcher": "^2.1.1", "jambonz-db-helpers": "^0.3.2", - "jambonz-realtimedb-helpers": "^0.1.7", + "jambonz-realtimedb-helpers": "^0.1.8", "jambonz-stats-collector": "^0.0.3", "moment": "^2.24.0", "parse-url": "^5.0.1",