From 8e200251ca44e856b055c8b463f651d460c79c25 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Sun, 23 Jul 2023 11:26:57 -0400 Subject: [PATCH] slight change to pino logger construction (#206) * slight change to pino logger construction * remove console.log in test * added test logging back in * test --- lib/logger.js | 12 ++++-------- test/recent-calls.js | 36 +++++++++++------------------------- 2 files changed, 15 insertions(+), 33 deletions(-) diff --git a/lib/logger.js b/lib/logger.js index 0da582f5..7909b9af 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -1,11 +1,7 @@ -const opts = Object.assign({ - timestamp: () => { - return `, "time": "${new Date().toISOString()}"`; - } -}, { +const opts = { level: process.env.JAMBONES_LOGLEVEL || 'info' -}); - -const logger = require('pino')(opts); +}; +const pino = require('pino'); +const logger = pino(opts, pino.destination(1, {sync: false})); module.exports = logger; diff --git a/test/recent-calls.js b/test/recent-calls.js index 4fedaf0c..0c3116bc 100644 --- a/test/recent-calls.js +++ b/test/recent-calls.js @@ -75,32 +75,29 @@ test('recent calls tests', async(t) => { auth: authUser, json: true, }); + console.log(JSON.stringify(result)); t.ok(result.data.length === 5, 'retrieved 5 recent calls by account'); - result = await request.get(`/Accounts/${account_sid}/RecentCalls?page=1&count=25&filter=16`, { - auth: authUser, - json: true, - }); - t.ok(result.data.length === 0, 'retrieved 5 recent calls by account and from'); - - result = await request.get(`/Accounts/${account_sid}/RecentCalls?page=1&count=25&filter=15`, { + result = await request.get(`/Accounts/${account_sid}/RecentCalls?page=1&count=25&filter=1508`, { auth: authUser, json: true, }); + console.log(JSON.stringify(result)); t.ok(result.data.length === 5, 'retrieved 5 recent calls by account and from'); - result = await request.get(`/Accounts/${account_sid}/RecentCalls?page=1&count=25&filter=19`, { + result = await request.get(`/Accounts/${account_sid}/RecentCalls?page=1&count=25&filter=15080`, { auth: authUser, json: true, }); - t.ok(result.data.length === 0, 'retrieved 5 recent calls by account and to'); + console.log(JSON.stringify(result)); + t.ok(result.data.length === 0, 'retrieved 0 recent calls by account and non-matching from'); - result = await request.get(`/Accounts/${account_sid}/RecentCalls?page=1&count=25&filter=18`, { + result = await request.get(`/Accounts/${account_sid}/RecentCalls?page=1&count=25&filter=1888`, { auth: authUser, json: true, }); + console.log(JSON.stringify(result)); t.ok(result.data.length === 5, 'retrieved 5 recent calls by account and to'); - //console.log({data: result.data}, 'Account recent calls'); /* query last 7 days by service provider */ result = await request.get(`/ServiceProviders/${service_provider_sid}/RecentCalls?page=1&count=25`, { @@ -109,29 +106,18 @@ test('recent calls tests', async(t) => { }); t.ok(result.data.length === 5, 'retrieved 5 recent calls by service provider'); - result = await request.get(`/ServiceProviders/${service_provider_sid}/RecentCalls?page=1&count=25&filter=16`, { - auth: authAdmin, - json: true, - }); - t.ok(result.data.length === 0, 'retrieved 5 recent calls by service provider and from'); - - result = await request.get(`/ServiceProviders/${service_provider_sid}/RecentCalls?page=1&count=25&filter=15`, { + result = await request.get(`/ServiceProviders/${service_provider_sid}/RecentCalls?page=1&count=25&filter=1508`, { auth: authAdmin, json: true, }); t.ok(result.data.length === 5, 'retrieved 5 recent calls by service provider and from'); - result = await request.get(`/ServiceProviders/${service_provider_sid}/RecentCalls?page=1&count=25&filter=19`, { - auth: authAdmin, - json: true, - }); - t.ok(result.data.length === 0, 'retrieved 5 recent calls by service provider and to'); - - result = await request.get(`/ServiceProviders/${service_provider_sid}/RecentCalls?page=1&count=25&filter=18`, { + result = await request.get(`/ServiceProviders/${service_provider_sid}/RecentCalls?page=1&count=25&filter=1888`, { auth: authAdmin, json: true, }); t.ok(result.data.length === 5, 'retrieved 5 recent calls by service provider and to'); + //console.log({data: result.data}, 'SP recent calls'); /* pull sip traces and pcap from homer */