GELF appender: move facility key into a custom field if present

At the same time, don't assign a default value as the field is optional
according to the GELF spec v1.1.
This commit is contained in:
Jens John 2014-07-10 14:07:38 +09:00
parent f44af56f9e
commit 5b2d840472

View File

@ -48,7 +48,9 @@ function gelfAppender (layout, host, port, hostname, facility) {
host = host || 'localhost';
port = port || 12201;
hostname = hostname || require('os').hostname();
facility = facility || 'nodejs-server';
if(facility) {
customFields['_facility'] = facility;
}
layout = layout || layouts.messagePassThroughLayout;
var defaultCustomFields = customFields || {};
@ -103,7 +105,6 @@ function gelfAppender (layout, host, port, hostname, facility) {
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;
}