GELF appender - test case covers custom fields, remove unused
console.log
This commit is contained in:
parent
837d007de3
commit
baaebef2ed
@ -43,7 +43,6 @@ function gelfAppender (layout, host, port, hostname, facility, customFields) {
|
|||||||
layout = layout || layouts.messagePassThroughLayout;
|
layout = layout || layouts.messagePassThroughLayout;
|
||||||
|
|
||||||
var defaultCustomFields = customFields || {};
|
var defaultCustomFields = customFields || {};
|
||||||
console.log(defaultCustomFields)
|
|
||||||
|
|
||||||
var client = dgram.createSocket("udp4");
|
var client = dgram.createSocket("udp4");
|
||||||
|
|
||||||
|
@ -135,5 +135,51 @@ vows.describe('log4js gelfAppender').addBatch({
|
|||||||
assert.equal(message.facility, 'nonsense');
|
assert.equal(message.facility, 'nonsense');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
'with custom fields options': {
|
||||||
|
topic: function() {
|
||||||
|
var setup = setupLogging({
|
||||||
|
host: 'somewhere',
|
||||||
|
port: 12345,
|
||||||
|
hostname: 'cheese',
|
||||||
|
facility: 'nonsense',
|
||||||
|
customFields: {
|
||||||
|
_every1: 'Hello every one',
|
||||||
|
_every2: 'Hello every two'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var myFields = {
|
||||||
|
GELF: true,
|
||||||
|
_every2: 'Overwritten!',
|
||||||
|
_myField: 'This is my field!'
|
||||||
|
};
|
||||||
|
setup.logger.debug(myFields, "Just testing.");
|
||||||
|
return setup;
|
||||||
|
},
|
||||||
|
'the dgram packet': {
|
||||||
|
topic: function(setup) {
|
||||||
|
return setup.dgram;
|
||||||
|
},
|
||||||
|
'should pick up the options': function(dgram) {
|
||||||
|
assert.equal(dgram.socket.host, 'somewhere');
|
||||||
|
assert.equal(dgram.socket.port, 12345);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'the uncompressed packet': {
|
||||||
|
topic: function(setup) {
|
||||||
|
var message = JSON.parse(setup.compress.uncompressed);
|
||||||
|
return message;
|
||||||
|
},
|
||||||
|
'should pick up the options': function(message) {
|
||||||
|
assert.equal(message.host, 'cheese');
|
||||||
|
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
|
||||||
|
assert.equal(message.short_message, 'Just testing.'); // skip the field object
|
||||||
|
assert.equal(message.full_message, 'Just testing.'); // should be as same as short_message
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}).export(module);
|
}).export(module);
|
||||||
|
Loading…
Reference in New Issue
Block a user