Skip to content

Commit

Permalink
Merge pull request #294 from Skiggz/gelf-fix
Browse files Browse the repository at this point in the history
Remove GELF flag when capturing custom fields
  • Loading branch information
nomiddlename committed May 12, 2015
2 parents 9fe32d0 + 1454ae5 commit c76fe09
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/appenders/gelf.js
Expand Up @@ -85,6 +85,8 @@ function gelfAppender (layout, host, port, hostname, facility) {
var firstData = data[0];

if (!firstData.GELF) return; // identify with GELF field defined
// Remove the GELF key, some gelf supported logging systems drop the message with it
delete firstData.GELF;
Object.keys(firstData).forEach(function(key) {
// skip _id field for graylog2, skip keys not starts with UNDERSCORE
if (key.match(/^_/) || key !== "_id") {
Expand Down
1 change: 1 addition & 0 deletions test/gelfAppender-test.js
Expand Up @@ -244,6 +244,7 @@ vows.describe('log4js gelfAppender').addBatch({
},
'should pick up the options': function(message) {
assert.equal(message.host, 'cheese');
assert.isUndefined(message.GELF); // make sure flag was removed
assert.equal(message._facility, 'nonsense');
assert.equal(message._every1, 'Hello every one'); // the default value
assert.equal(message._every2, 'Overwritten!'); // the overwritten value
Expand Down

0 comments on commit c76fe09

Please sign in to comment.