* Clean up some logs

* Add serializer for 'err' in logs for passing full err object
* Don't dump HUGE message lists to log during new scan
This commit is contained in:
Bryan Ashby 2016-07-16 13:05:32 -06:00
parent 14c8b39a9e
commit 485711b5da
4 changed files with 44 additions and 19 deletions

View File

@ -218,7 +218,11 @@ function startListening(cb) {
moduleUtil.loadModulesForCategory('servers', (err, module) => {
if(err) {
logger.log.info(err);
if('EENIGMODDISABLED' === err.code) {
logger.log.debug(err.message);
} else {
logger.log.info( { err : err }, 'Failed loading module');
}
return;
}
@ -228,14 +232,14 @@ function startListening(cb) {
return;
}
const moduleInst = new module.getModule();
let server;
try {
server = moduleInst.createServer();
} catch(e) {
logger.log.warn(e, 'Exception caught creating server!');
return;
}
const moduleInst = new module.getModule();
let server;
try {
server = moduleInst.createServer();
} catch(e) {
logger.log.warn(e, 'Exception caught creating server!');
return;
}
// :TODO: handle maxConnections, e.g. conf.maxConnections

View File

@ -2,7 +2,6 @@
'use strict';
var bunyan = require('bunyan');
var miscUtil = require('./misc_util.js');
var paths = require('path');
var fs = require('fs');
@ -57,7 +56,8 @@ module.exports = {
stream : ringBuffer,
level : 'trace'
}*/
]
],
serializers: { err : bunyan.stdSerializers.err } // handle 'err' fields with stack/etc.
});
}
};

View File

@ -24,7 +24,9 @@ function loadModuleEx(options, cb) {
const modConfig = _.isObject(Config[options.category]) ? Config[options.category][options.name] : null;
if(_.isObject(modConfig) && false === modConfig.enabled) {
return cb(new Error(`Module "${options.name}" is disabled`));
const err = new Error(`Module "${options.name}" is disabled`);
err.code = 'EENIGMODDISABLED';
return cb(err);
}
//

View File

@ -165,12 +165,31 @@ function NewScanModule(options) {
},
function displayMessageList(msgList) {
if(msgList && msgList.length > 0) {
var nextModuleOpts = {
const nextModuleOpts = {
extraArgs: {
messageAreaTag : currentArea.areaTag,
messageList : msgList,
}
};
//
// provide a serializer so we don't dump *huge* bits of information to the log
// due to the size of |messageList|
// https://github.com/trentm/node-bunyan/issues/189
//
nextModuleOpts.extraArgs.toJSON = function() {
let logMsgList;
if(this.messageList.length <= 4) {
logMsgList = this.messageList;
} else {
logMsgList = this.messageList.slice(0, 2).concat(this.messageList.slice(-2));
}
return {
messageAreaTag : this.messageAreaTag,
partialMessageList : logMsgList,
};
};
self.gotoMenu(config.newScanMessageList || 'newScanMessageList', nextModuleOpts);
} else {
@ -221,13 +240,13 @@ NewScanModule.prototype.mciReady = function(mciData, cb) {
},
function performCurrentStepScan(callback) {
switch(self.currentStep) {
case 'messageConferences' :
self.newScanMessageConference( () => {
callback(null); // finished
});
case 'messageConferences' :
self.newScanMessageConference( () => {
callback(null); // finished
});
break;
default : return callback(null);
default : return callback(null);
}
}
],