New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

winston-syslog

Package Overview
Dependencies
Maintainers
3
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

winston-syslog - npm Package Compare versions

Comparing version 1.1.2 to 1.2.1

LICENSE

17

lib/winston-syslog.js

@@ -15,3 +15,2 @@ /*

winston = require('winston'),
unix = require('unix-dgram'),
common = require('winston/lib/winston/common');

@@ -39,4 +38,2 @@

options = options || {};
// Set transport name
this.name = 'syslog';
//

@@ -82,3 +79,3 @@ // Setup connection state

//
this.localhost = options.localhost || 'localhost';
this.localhost = typeof options.localhost !== 'undefined' ? options.localhost : 'localhost';
this.type = options.type || 'BSD';

@@ -115,3 +112,3 @@ this.facility = options.facility || 'local0';

//
Syslog.prototype.name = 'Syslog';
Syslog.prototype.name = 'syslog';
//

@@ -233,3 +230,6 @@ // ### function log (level, msg, [meta], callback)

if (attempt >= max || (self.queue.length === 0 && self.inFlight <= 0)) {
self.socket.close();
if (self.socket) {
self.socket.close();
}
self.emit('closed', self.socket);

@@ -270,3 +270,3 @@ }

else if (self.protocol === 'unix') {
this.socket = new unix.createSocket('unix_dgram');
this.socket = require('unix-dgram').createSocket('unix_dgram');
}

@@ -364,5 +364,6 @@ else {

this.socket = new unix.createSocket('unix_dgram');
this.socket = require('unix-dgram').createSocket('unix_dgram');
this.socket.on('error', function (err) {
if (err.syscall === 'connect') {
self.socket.close();
self.socket = null;

@@ -369,0 +370,0 @@ cb(err);

{
"name": "winston-syslog",
"description": "A syslog transport for winston",
"version": "1.1.2",
"version": "1.2.1",
"author": "Charlie Robbins <charlie.robbins@gmail.com>",

@@ -25,9 +25,11 @@ "contributors": [

"cycle": "~1.0.3",
"glossy": "0.x.x",
"glossy": "0.x.x"
},
"optionalDependencies": {
"unix-dgram": "~0.2.1"
},
},
"devDependencies": {
"stylezero": "~2.1.1",
"vows": "0.8.x",
"winston": "^0.9.0"
"stylezero": "^2.3.0",
"vows": "~0.8.1",
"winston": "^2.1.0"
},

@@ -37,7 +39,8 @@ "main": "./lib/winston-syslog",

"pretest": "stylezero lib/ test/",
"test": "sudo vows test/*-test.js --spec"
"test": "vows test/*-test.js --spec"
},
"engines": {
"node": ">= 0.8.0"
}
},
"license": "MIT"
}

@@ -22,8 +22,18 @@ /*

function closeTopic() {
function closeTopicInfo() {
var transport = new winston.transports.Syslog(),
logger = new winston.Logger({ transports: [transport] });
logger.log('info', 'Test message to actually use socket');
logger.remove(transport);
return transport;
}
function closeTopicDebug() {
var transport = new winston.transports.Syslog(),
logger = new winston.Logger({ transports: [transport] });
logger.log('debug', 'Test message to actually use socket');
logger.remove({ name: 'syslog' });
logger.remove(transport);

@@ -45,24 +55,50 @@ return transport;

assert.equal(transport.queue.length, 0); // This is > 0 because winston-syslog.js line 124
})
//
// TODO: Figure out why this hangs.
//
// 'on close': {
// topic: closeTopic,
// on: {
// closed: {
// 'closes the socket': function (socket) {
// assert.isNull(socket._handle);
// }
// }
// }
// }
}),
teardown: function () {
transport.close();
},
'on close after not really writing': {
topic: closeTopicDebug,
on: {
closed: {
'closes the socket': function (socket) {
assert.isNull(socket);
}
}
}
},
'on close after really writing': {
topic: closeTopicInfo,
on: {
closed: {
'closes the socket': function (socket) {
assert.isNull(socket._handle);
}
}
}
},
'localhost option': {
'should default to localhost': function () {
var transport = new winston.transports.Syslog();
assert.equal(transport.localhost, 'localhost');
transport.close();
},
'should accept other falsy entries as valid': function () {
var transport = new winston.transports.Syslog({ localhost: null });
assert.isNull(transport.localhost);
transport.close();
transport = new winston.transports.Syslog({ localhost: false });
assert.equal(transport.localhost, false);
transport.close();
}
},
'adding / removing transport to syslog': {
'should just work': function () {
winston.add(winston.transports.Syslog);
winston.remove(winston.transports.Syslog);
winston.add(winston.transports.Syslog);
winston.remove(winston.transports.Syslog);
}
}
}
}).export(module);
//
// TODO: Close all the syslog connections so vows exits.
//
setTimeout(function () {
process.exit(0);
}, 5000);

@@ -28,6 +28,6 @@ var fs = require('fs');

'Trying to log to a non-existant log server': {
'should enqueue the log message': function () {
topic: function () {
var self = this;
transport.once('error', function (err) {
assert(err);
assert.equal(err.syscall, 'connect');
self.callback(null, err);
});

@@ -40,2 +40,6 @@

});
},
'should enqueue the log message': function (err) {
assert(err);
assert.equal(err.syscall, 'connect');
}

@@ -45,7 +49,13 @@ }

'Logging when log server is up': {
'should log enqueued msg and then new msg': function () {
topic: function () {
var self = this;
var n = 0;
server = unix.createSocket('unix_dgram', function (buf, rinfo) {
parser.parse(buf, function (d) {
assert.equal(d.message, 'data' + (++n));
++n;
assert(n <= 2);
assert.equal(d.message, 'node[' + process.pid + ']: debug: data' + n);
if (n === 2) {
self.callback();
}
});

@@ -58,2 +68,5 @@ });

});
},
'should print both the enqueed and the new msg': function (err) {
assert.ifError(err);
}

@@ -63,9 +76,6 @@ }

'Logging if server goes down again': {
'should enqueue the log message': function () {
topic: function () {
var self = this;
transport.once('error', function (err) {
assert(err);
assert.equal(err.syscall, 'send');
process.nextTick(function () {
assert.equal(transport.queue.length, 1);
});
self.callback(null, err);
});

@@ -77,12 +87,11 @@

assert.ifError(err);
assert.equal(transport.queue.length, 1);
});
},
'should enqueue the log message': function (err) {
assert(err);
assert.equal(err.syscall, 'send');
transport.close();
}
}
}).export(module);
//
// TODO: Close all the syslog connections so vows exits.
//
setTimeout(function () {
process.exit(0);
}, 5000);
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc