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

winston-papertrail

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

winston-papertrail - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

102

lib/winston-papertrail.js

@@ -63,2 +63,4 @@ /*

*
* @param {Boolean} [options.flushOnClose] send remaining messages before closing (false)
*
* @type {Function}

@@ -137,2 +139,4 @@ */

self.flushOnClose = options.flushOnClose || false;
self.producer = new syslogProducer({ facility: self.facility });

@@ -230,3 +234,3 @@

self.emit('error', err);
self._silentErrorEmitter(err);

@@ -250,7 +254,7 @@ // We may be disconnected from the papertrail endpoint for any number of reasons;

// This is to keep the buffer from growing unbounded
if (self.loggingEnabled &&
(self.totalRetries >= (self.maximumAttempts))) {
self.loggingEnabled = false;
self.emit('error', new Error('Max entries eclipsed, disabling buffering'));
}
if (self.loggingEnabled && (self.totalRetries >= (self.maximumAttempts)))
{
self.loggingEnabled = false;
self._silentErrorEmitter(new Error('Max entries eclipsed, disabling buffering'));
}

@@ -265,16 +269,12 @@ // continue

function onConnected() {
// Reset our variables
self.loggingEnabled = true;
self.currentRetries = 0;
self.totalRetries = 0;
self.connectionDelay = options.connectionDelay || 1000;
// Reset our variables
self.loggingEnabled = true;
self.currentRetries = 0;
self.totalRetries = 0;
self.connectionDelay = options.connectionDelay || 1000;
self.emit('connect', 'Connected to Papertrail at ' + self.host + ':' + self.port);
self.emit('connect', 'Connected to Papertrail at ' + self.host + ':' + self.port);
// Did we get messages buffered
if (self.buffer.length > 0) {
self.stream.write(self.buffer);
self.buffer = '';
}
}
self.processBuffer();
}
};

@@ -379,3 +379,3 @@

// If the incoming message has multiple lines, break them and format each
// line as it's own message
// line as its own message
for (var i = 0; i < lines.length; i++) {

@@ -402,3 +402,4 @@

if (this.stream && this.stream.writable) {
this.stream.write(msg, callback);
this.processBuffer();
this.stream.write(msg, callback);
}

@@ -411,2 +412,26 @@ else if (this.loggingEnabled && this.buffer.length < this.maxBufferSize) {

/**
* If we have anything buffered, try to write it to the stream if we can before we log new messages
*/
Papertrail.prototype.processBuffer = function() {
var self = this;
// Did we have buffered messages?
if (this.buffer.length <= 0) {
return;
}
// Is the stream writable?
if (!this.stream || !this.stream.writable) {
return;
}
this.stream.write(this.buffer, function() {
if (!self.buffer.length) {
self.stream.emit('empty');
}
});
this.buffer = '';
};
/**
* Papertrail.close

@@ -422,5 +447,14 @@ *

if (self.stream) {
self.stream.end();
}
if (self.stream) {
if (self.flushOnClose && self.buffer.length) {
self.stream.on('empty', function() {
// TODO: some kind of guard here to avoid infinite recursion?
self.close();
});
}
else {
self.stream.end();
}
}
// if there's no stream yet, that means we're still connecting

@@ -434,1 +468,23 @@ // lets wire a connect handler, and then invoke close again

};
/**
* The goal here is to ignore connection errors by default without triggering an uncaughtException.
* You can still bind your own error handler as normal, but if you haven't overridden it, connection errors
* will be logged to the console by default.
*
* Notes: This is meant to fix usability issues #20, and #49
*
* @param err
* @private
*/
Papertrail.prototype._silentErrorEmitter = function(err) {
var count = this.listeners('error').length;
if (count > 0) {
// the goal here is to ensure someone is catching this event, instead of potentially
// causing the process to exit.
this.emit('error', err);
}
else {
console.error('Papertrail connection error: ', err);
}
};
{
"name": "winston-papertrail",
"description": "A Papertrail transport for winston",
"version": "1.0.3",
"version": "1.0.4",
"author": "Ken Perkins <ken.perkins@rackspace.com>",

@@ -6,0 +6,0 @@ "repository": {

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