winston-syslog
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -74,5 +74,5 @@ /* | ||
this.producer = new Producer({ | ||
type: this.type, | ||
appName: this.appName, | ||
pid: this.pid, | ||
type: this.type, | ||
appName: this.appName, | ||
pid: this.pid, | ||
facility: this.facility | ||
@@ -125,3 +125,3 @@ }); | ||
} | ||
level = level === "warn" ? "warning" : level; | ||
level = level === 'warn' ? 'warning' : level; | ||
const output = info[MESSAGE]; | ||
@@ -210,3 +210,10 @@ | ||
if (this.socket) { | ||
this.socket.destroy(); | ||
if (this.socket.destroy) { | ||
// https://nodejs.org/api/net.html#net_socket_destroy_exception | ||
this.socket.destroy(); | ||
} else if (this.socket.close) { | ||
// https://nodejs.org/api/dgram.html#dgram_socket_close_callback | ||
// https://www.npmjs.com/package/unix-dgram#socketclose | ||
this.socket.close(); | ||
} | ||
} | ||
@@ -231,3 +238,6 @@ | ||
const proto = this.protocol === 'udp' ? 'udp4' : this.protocol; | ||
this.socket = new dgram.Socket(proto); | ||
// https://nodejs.org/api/all.html#dgram_class_dgram_socket | ||
this.socket = dgram.createSocket({ | ||
type: proto | ||
}); | ||
} | ||
@@ -328,4 +338,9 @@ | ||
}).on('timeout', () => { | ||
if (this.socket.readyState !== 'open') { | ||
if (this.socket.destroy) { | ||
// https://nodejs.org/api/net.html#net_socket_settimeout_timeout_callback | ||
this.socket.destroy(); | ||
} else if (this.socket.close) { | ||
// https://nodejs.org/api/dgram.html#dgram_socket_close_callback | ||
// https://www.npmjs.com/package/unix-dgram#socketclose | ||
this.socket.close(); | ||
} | ||
@@ -332,0 +347,0 @@ }); |
{ | ||
"name": "winston-syslog", | ||
"description": "A syslog transport for winston", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"author": "Charlie Robbins <charlie.robbins@gmail.com>", | ||
@@ -32,3 +32,3 @@ "contributors": [ | ||
"optionalDependencies": { | ||
"unix-dgram": "^2.0.2" | ||
"unix-dgram": "2.0.2" | ||
}, | ||
@@ -39,3 +39,3 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"eslint-config-populist": "^4.1.0", | ||
"eslint-config-populist": "4.2.0", | ||
"vows": "^0.8.2", | ||
@@ -42,0 +42,0 @@ "winston": "^3.0.0" |
@@ -5,3 +5,3 @@ 'use strict'; | ||
const assert = require('assert'); | ||
const winston = require('winston'); | ||
const Syslog = require('../lib/winston-syslog.js').Syslog; | ||
const dgram = require('dgram'); | ||
@@ -36,3 +36,3 @@ const parser = require('glossy').Parse; | ||
transport = new winston.transports.Syslog({ | ||
transport = new Syslog({ | ||
port: PORT | ||
@@ -57,3 +57,3 @@ }); | ||
transport = new winston.transports.Syslog({ | ||
transport = new Syslog({ | ||
port: PORT, | ||
@@ -80,3 +80,3 @@ localhost: null | ||
transport = new winston.transports.Syslog({ | ||
transport = new Syslog({ | ||
port: PORT, | ||
@@ -104,3 +104,3 @@ type: '5424', | ||
transport = new winston.transports.Syslog({ | ||
transport = new Syslog({ | ||
port: PORT, | ||
@@ -129,3 +129,3 @@ type: '5424', | ||
'opening fake syslog server': { | ||
topic: function () { | ||
'topic': function () { | ||
var self = this; | ||
@@ -140,6 +140,6 @@ server = dgram.createSocket('udp4'); | ||
'Custom producer': { | ||
topic: function () { | ||
'topic': function () { | ||
var self = this; | ||
server.once('message', function (msg) { | ||
self.callback(undefined, msg.toString()); | ||
self.callback(null, msg.toString()); | ||
}); | ||
@@ -149,6 +149,6 @@ | ||
CustomProducer.prototype.produce = function (opts) { | ||
return 'test ' + opts.message; | ||
return 'test ' + opts.severity + ': ' + opts.message; | ||
}; | ||
transport = new winston.transports.Syslog({ | ||
transport = new Syslog({ | ||
port: PORT, | ||
@@ -158,3 +158,3 @@ customProducer: CustomProducer | ||
transport.log('debug', 'ping', null, function (err) { | ||
transport.log({ [LEVEL]: 'debug', [MESSAGE]: 'ping' }, function (err) { | ||
assert.ifError(err); | ||
@@ -168,3 +168,3 @@ }); | ||
}, | ||
teardown: function () { | ||
'teardown': function () { | ||
server.close(); | ||
@@ -171,0 +171,0 @@ } |
@@ -37,4 +37,3 @@ /* eslint no-sync: "off" */ | ||
transport.log({ [LEVEL]: 'debug', [MESSAGE]: `data${++times}` }, function (err) { | ||
assert(err); | ||
assert.equal(err.syscall, 'connect'); | ||
assert.equal(null, err); | ||
assert.equal(transport.queue.length, 1); | ||
@@ -41,0 +40,0 @@ }); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29860
723