Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

winston-syslog

Package Overview
Dependencies
Maintainers
1
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 0.2.2 to 0.2.3

.npmignore

77

lib/winston-syslog.js

@@ -13,3 +13,4 @@ /*

glossy = require('glossy'),
winston = require('winston');
winston = require('winston'),
unix = require('unix-dgram');

@@ -34,4 +35,6 @@ var levels = Object.keys({

var Syslog = exports.Syslog = function (options) {
winston.Transport.call(this, options);
options = options || {};
// Set transport name
this.name = 'syslog';
//

@@ -43,2 +46,3 @@ // Setup connection state

this.queue = [];
this.inFlight = 0;

@@ -51,2 +55,3 @@ //

this.path = options.path || null;
this.app_id = options.app_id || null;
this.protocol = options.protocol || 'udp4';

@@ -70,2 +75,3 @@ this.isDgram = /^udp|unix/.test(this.protocol);

this.pid = options.pid || process.pid;
this.app_name = options.app_name || process.title;

@@ -78,2 +84,3 @@ //

type: this.type,
appName: this.app_name,
pid: this.pid,

@@ -96,2 +103,6 @@ facility: this.facility

//
// Expose the name of this Transport on the prototype
//
Syslog.prototype.name = 'Syslog';
//
// ### function log (level, msg, [meta], callback)

@@ -119,4 +130,5 @@ // #### @level {string} Target level to log to

host: this.localhost,
app_id: this.app_id || process.title,
date: new Date(),
message: data
message: meta ? JSON.stringify(data) : msg
});

@@ -141,2 +153,3 @@

self.emit('logged');
self.inFlight--;
}

@@ -149,3 +162,4 @@

buffer = new Buffer(syslogMsg);
if (self.protocol.match(/^udp/)) {
if (self.protocol.match(/^udp/)) {
self.inFlight++;
self.socket.send(buffer, 0, buffer.length, self.port, self.host, onError);

@@ -164,4 +178,21 @@ }

};
//
// ### function close ()
// Closes the socket used by this transport freeing the resource.
//
Syslog.prototype.close = function () {
var self = this,
max = 6,
attempt = 0;
(function _close(){
if(attempt>=max || (self.queue.length === 0 && self.inFlight <= 0)){
self.socket.close();
self.emit('closed', self.socket);
}else{
attempt++
setTimeout(_close, 200 * attempt);
}
}());
}
//
// ### function connect (callback)

@@ -179,3 +210,3 @@ // #### @callback {function} Continuation to respond to when complete.

if (this.socket) {
return this.socket.readyState === 'open'
return (!this.socket.readyState) || (this.socket.readyState === 'open')
? callback(null)

@@ -189,4 +220,10 @@ : callback(true);

if (this.isDgram) {
this.socket = new dgram.Socket(this.protocol);
readyEvent = 'listening';
if (self.protocol.match(/^udp/)) {
this.socket = new dgram.Socket(this.protocol);
}
else {
this.socket = new unix.createSocket('unix_dgram');
}
return callback(null);
}

@@ -207,2 +244,3 @@ else {

self.emit('logged');
self.inFlight--;
}

@@ -214,4 +252,5 @@

//
callback(true);
callback();
//

@@ -226,14 +265,3 @@ // Listen to the appropriate events on the socket that

//
if (self.isDgram) {
var buffer = new Buffer(self.queue.join(''));
if (self.protocol.match(/^udp/)) {
self.socket.send(buffer, 0, buffer.length, self.port, self.host, onError);
}
else {
self.socket.send(buffer, 0, buffer.length, self.path, onError);
}
}
else {
self.socket.write(self.queue.join(''), 'utf8', onError);
}
self.socket.write(self.queue.join(''), 'utf8', onError);

@@ -270,10 +298,3 @@ self.emit('logged');

if (self.protocol.match(/^udp/)) {
return this.socket.bind(this.port, this.host);
}
else if (self.protocol.match(/^unix/)){
return this.socket.bind(this.path);
}
this.socket.connect(this.port, this.host);
};
{
"name": "winston-syslog",
"description": "A syslog transport for winston",
"version": "0.2.2",
"version": "0.2.3",
"author": "Charlie Robbins <charlie.robbins@gmail.com>",

@@ -11,11 +11,12 @@ "contributors": [

"type": "git",
"url": "http://github.com/indexzero/winston-syslog.git"
"url": "http://github.com/indexzero/winston-syslog.git"
},
"keywords": ["logging", "sysadmin", "tools", "winston", "syslog"],
"dependencies": {
"glossy": "0.x.x"
"glossy": "0.x.x",
"unix-dgram": ">= 0.0.1"
},
"devDependencies": {
"winston": "0.4.x",
"vows": "0.5.x"
"winston": "0.5.x",
"vows": "0.6.x"
},

@@ -22,0 +23,0 @@ "main": "./lib/winston-syslog",

@@ -49,2 +49,3 @@ # winston-syslog

* __type:__ The type of the syslog protocol to use (Default: `BSD`).
* __app_name:__ The name of the application (Default: `process.title`).

@@ -58,3 +59,3 @@ *Metadata:* Logged as string compiled by [glossy][3].

var winston = require('winston');
winston.setLevels(winston.config.syslog);
winston.setLevels(winston.config.syslog.levels);
```

@@ -61,0 +62,0 @@

@@ -22,2 +22,12 @@ /*

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

@@ -33,4 +43,13 @@

assert.isTrue(ok);
})
assert.equal(transport.queue.length, 0); //This is > 0 because winston-syslog.js line 124
}),
topic : closeTopic,
on:{
"closed" :{
"closes the socket" :function(socket){
assert.isNull(socket._handle);
}
}
}
}
}).export(module);
}).export(module);
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