mirror of
https://github.com/log4js-node/log4js-node.git
synced 2025-12-08 19:26:01 +00:00
Merge pull request #371 from artem-karpenko/master
Shutdown for gelf appender
This commit is contained in:
commit
4fb05d60d4
@ -25,6 +25,8 @@ levelMapping[levels.WARN] = LOG_WARNING;
|
||||
levelMapping[levels.ERROR] = LOG_ERR;
|
||||
levelMapping[levels.FATAL] = LOG_CRIT;
|
||||
|
||||
var client;
|
||||
|
||||
/**
|
||||
* GELF appender that supports sending UDP packets to a GELF compatible server such as Graylog
|
||||
*
|
||||
@ -56,7 +58,7 @@ function gelfAppender (layout, host, port, hostname, facility) {
|
||||
defaultCustomFields['_facility'] = facility;
|
||||
}
|
||||
|
||||
var client = dgram.createSocket("udp4");
|
||||
client = dgram.createSocket("udp4");
|
||||
|
||||
process.on('exit', function() {
|
||||
if (client) client.close();
|
||||
@ -140,5 +142,13 @@ function configure(config) {
|
||||
return gelfAppender(layout, config);
|
||||
}
|
||||
|
||||
function shutdown(cb) {
|
||||
if (client) {
|
||||
client.close(cb);
|
||||
client = null;
|
||||
}
|
||||
}
|
||||
|
||||
exports.appender = gelfAppender;
|
||||
exports.configure = configure;
|
||||
exports.shutdown = shutdown;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user