Merge 2ion-gelf-spec-v1.1-compliance into master
This commit is contained in:
commit
a06478632e
@ -48,11 +48,14 @@ function gelfAppender (layout, host, port, hostname, facility) {
|
||||
host = host || 'localhost';
|
||||
port = port || 12201;
|
||||
hostname = hostname || require('os').hostname();
|
||||
facility = facility || 'nodejs-server';
|
||||
layout = layout || layouts.messagePassThroughLayout;
|
||||
|
||||
var defaultCustomFields = customFields || {};
|
||||
|
||||
if(facility) {
|
||||
defaultCustomFields['_facility'] = facility;
|
||||
}
|
||||
|
||||
var client = dgram.createSocket("udp4");
|
||||
|
||||
process.on('exit', function() {
|
||||
@ -98,11 +101,10 @@ function gelfAppender (layout, host, port, hostname, facility) {
|
||||
addCustomFields(loggingEvent, msg);
|
||||
msg.short_message = layout(loggingEvent);
|
||||
|
||||
msg.version="1.0";
|
||||
msg.version="1.1";
|
||||
msg.timestamp = msg.timestamp || new Date().getTime() / 1000; // log should use millisecond
|
||||
msg.host = hostname;
|
||||
msg.level = levelMapping[loggingEvent.level || levels.DEBUG];
|
||||
msg.facility = facility;
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
@ -115,10 +115,9 @@ vows.describe('log4js gelfAppender').addBatch({
|
||||
return message;
|
||||
},
|
||||
'should be in the gelf format': function(message) {
|
||||
assert.equal(message.version, '1.0');
|
||||
assert.equal(message.version, '1.1');
|
||||
assert.equal(message.host, require('os').hostname());
|
||||
assert.equal(message.level, 6); //INFO
|
||||
assert.equal(message.facility, 'nodejs-server');
|
||||
assert.equal(message.short_message, 'This is a test');
|
||||
}
|
||||
}
|
||||
@ -165,7 +164,7 @@ vows.describe('log4js gelfAppender').addBatch({
|
||||
},
|
||||
'should pick up the options': function(message) {
|
||||
assert.equal(message.host, 'cheese');
|
||||
assert.equal(message.facility, 'nonsense');
|
||||
assert.equal(message._facility, 'nonsense');
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -245,7 +244,7 @@ vows.describe('log4js gelfAppender').addBatch({
|
||||
},
|
||||
'should pick up the options': function(message) {
|
||||
assert.equal(message.host, 'cheese');
|
||||
assert.equal(message.facility, 'nonsense');
|
||||
assert.equal(message._facility, 'nonsense');
|
||||
assert.equal(message._every1, 'Hello every one'); // the default value
|
||||
assert.equal(message._every2, 'Overwritten!'); // the overwritten value
|
||||
assert.equal(message._myField, 'This is my field!'); // the value for this message only
|
||||
|
Loading…
Reference in New Issue
Block a user