Skip to content

Commit

Permalink
Merge pull request #28 from jordanwalsh23/externalise_log_level
Browse files Browse the repository at this point in the history
added function to allow users to set the log level
  • Loading branch information
jordanwalsh23 committed Mar 23, 2017
2 parents 83727e9 + 644b633 commit ddea2ab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
13 changes: 7 additions & 6 deletions lib/index.js
Expand Up @@ -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({
Expand All @@ -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 } });
init({ log: { level: 'error', toConsole: false } });
7 changes: 6 additions & 1 deletion test/accountingtests.js
Expand Up @@ -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 = '';
Expand Down Expand Up @@ -45,6 +48,8 @@ before('init instance and set options', function(done) {

eventReceiver = currentApp.eventEmitter;



done();
})

Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit ddea2ab

Please sign in to comment.