Merge pull request #232 from GregoireDigbil/fix_loggly_formatting

Fix loggly formatting
This commit is contained in:
Gareth Jones 2014-08-20 09:11:12 +10:00
commit 9637be8a41

View File

@ -18,24 +18,17 @@ var layouts = require('../layouts')
*/
function logglyAppender(config, layout) {
var client = loggly.createClient(config);
if(!layout) layout = passThrough;
function packageMessage(loggingEvent) {
function BaseItem(level, msg) {
this.level = level || loggingEvent.level.toString();
this.category = loggingEvent.categoryName;
this.hostname = os.hostname().toString();
if (typeof msg !== 'undefined')
this.msg = msg;
};
var formattedMsg = passThrough(loggingEvent);
return new BaseItem(formattedMsg);
};
return function(loggingEvent) {
var a = layout ? layout(loggingEvent) : packageMessage(loggingEvent);
client.log(a, config.tags);
};
return function(loggingEvent) {
var msg = layout(loggingEvent);
client.log({
msg: msg,
level: loggingEvent.level.levelStr,
category: loggingEvent.categoryName,
hostname: os.hostname().toString(),
});
}
}
function configure(config) {