From 644b633e9a22c7075089bfbe06cc44d541f97e76 Mon Sep 17 00:00:00 2001 From: Jordan Walsh Date: Thu, 23 Mar 2017 16:53:05 +1100 Subject: [PATCH] added function to allow users to set the log level --- lib/index.js | 13 +++++++------ test/accountingtests.js | 7 ++++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/index.js b/lib/index.js index 35f1a3d6..b519a1b0 100644 --- a/lib/index.js +++ b/lib/index.js @@ -5,6 +5,12 @@ module.exports.PrivateApplication = require('./application').PrivateApplication; module.exports.PublicApplication = require('./application').PublicApplication; module.exports.PartnerApplication = require('./application').PartnerApplication; +module.exports.setLogLevel = function(logLevel, toConsole) { + logLevel = logLevel || "error"; + toConsole = toConsole || false; + logger.config({ level: logLevel, toConsole: toConsole }); +}; + function init(options) { logger.config({ level: options.log.level, toConsole: options.log.toConsole }); _.mixin({ @@ -28,9 +34,4 @@ function init(options) { }) } -/** - * Change the log level here to affect the whole application. - * This should be externalised so the consumer can define it. - */ - -init({ log: { level: 'debug', toConsole: false } }); \ No newline at end of file +init({ log: { level: 'error', toConsole: false } }); \ No newline at end of file diff --git a/test/accountingtests.js b/test/accountingtests.js index 6913184d..93471abe 100644 --- a/test/accountingtests.js +++ b/test/accountingtests.js @@ -14,6 +14,9 @@ process.on('uncaughtException', function(err) { console.log('uncaught', err) }) +//Change the log level +xero.setLogLevel('warn'); + var currentApp; var eventReceiver; var organisationCountry = ''; @@ -45,6 +48,8 @@ before('init instance and set options', function(done) { eventReceiver = currentApp.eventEmitter; + + done(); }) @@ -1052,7 +1057,7 @@ describe('regression tests', function() { var myInvoice = invoices[0]; var myContact = myInvoice.Contact; - var myCreditNoteAmount = myInvoice.Total / 2; //50% of total invoice + var myCreditNoteAmount = myInvoice.AmountDue / 2; //50% of total amount left //Create the credit note. var creditNoteData = {