manually merged TooTallNate's pull request #62
This commit is contained in:
parent
754ac2c5ac
commit
38a89dcf3d
@ -1,4 +1,4 @@
|
|||||||
var compress = require('compress-buffer').compress;
|
var zlib = require('zlib');
|
||||||
var layouts = require('../layouts');
|
var layouts = require('../layouts');
|
||||||
var levels = require('../levels');
|
var levels = require('../levels');
|
||||||
var dgram = require('dgram');
|
var dgram = require('dgram');
|
||||||
@ -67,12 +67,17 @@ function gelfAppender (layout, host, port, hostname, facility) {
|
|||||||
|
|
||||||
return function(loggingEvent) {
|
return function(loggingEvent) {
|
||||||
var message = preparePacket(loggingEvent);
|
var message = preparePacket(loggingEvent);
|
||||||
var packet = compress(new Buffer(JSON.stringify(message)));
|
zlib.gzip(new Buffer(JSON.stringify(message)), function(err, packet) {
|
||||||
if (packet.length > 8192) {
|
if (err) {
|
||||||
util.debug("Message packet length (" + packet.length + ") is larger than 8k. Not sending");
|
console.error(err.stack);
|
||||||
} else {
|
} else {
|
||||||
sendPacket(packet);
|
if (packet.length > 8192) {
|
||||||
}
|
util.debug("Message packet length (" + packet.length + ") is larger than 8k. Not sending");
|
||||||
|
} else {
|
||||||
|
sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,7 @@
|
|||||||
"lib": "lib"
|
"lib": "lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": "0.1.15",
|
"async": "0.1.15"
|
||||||
"compress-buffer": "0.5.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vows": "0.6.2",
|
"vows": "0.6.2",
|
||||||
|
@ -23,20 +23,20 @@ var vows = require('vows')
|
|||||||
return this.socket;
|
return this.socket;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
, fakeCompressBuffer = {
|
, fakeZlib = {
|
||||||
compress: function(objectToCompress) {
|
gzip: function(objectToCompress, callback) {
|
||||||
fakeCompressBuffer.uncompressed = objectToCompress;
|
fakeZlib.uncompressed = objectToCompress;
|
||||||
if (compressedLength) {
|
if (compressedLength) {
|
||||||
return { length: compressedLength };
|
callback(null, { length: compressedLength });
|
||||||
} else {
|
} else {
|
||||||
return "I've been compressed";
|
callback(null, "I've been compressed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
, appender = sandbox.require('../lib/appenders/gelf', {
|
, appender = sandbox.require('../lib/appenders/gelf', {
|
||||||
requires: {
|
requires: {
|
||||||
dgram: fakeDgram,
|
dgram: fakeDgram,
|
||||||
"compress-buffer": fakeCompressBuffer
|
zlib: fakeZlib
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ var vows = require('vows')
|
|||||||
log4js.addAppender(appender.configure(options || {}), category || "gelf-test");
|
log4js.addAppender(appender.configure(options || {}), category || "gelf-test");
|
||||||
return {
|
return {
|
||||||
dgram: fakeDgram,
|
dgram: fakeDgram,
|
||||||
compress: fakeCompressBuffer,
|
compress: fakeZlib,
|
||||||
logger: log4js.getLogger(category || "gelf-test")
|
logger: log4js.getLogger(category || "gelf-test")
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user