jeffbski/hapi-bunyan-lite — pull request #3 by a-c-m (2014-08-11 16:36:27+00:00)
Title: Adding a preProcess config option

This is a small feature which lets you manipulate the log with a custom function before its pushed out.

We've used it like this :

manifest.plugins['hapi-bunyan-lite'] = {
logger: myRootLogger,
defaultLogLevel: 'trace',
preProcessData: function preProcessData(objLog, event, tags, request) {

if (typeof event.data === 'string') {
event.data = {
msg: event.data
};
};

if (request) {
objLog.remoteAddress = request.remoteAddress;
objLog.host = request.host;
objLog.path = request.path;
objLog.method = request.method;
objLog.received = request.info.received;
objLog.msec = new Date().getTime() - request.info.received;
objLog.isAuthenticated = request.auth.isAuthenticated
}

}
};

Which makes the logs a joy to work with in http://www.elasticsearch.org/overview/kibana/ and lets us trace down bottle necks.