Socket
Socket
Sign inDemoInstall

bunyan-rotating-file-stream

Package Overview
Dependencies
24
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.5 to 1.0.6

.directory

4

CHANGES.md

@@ -5,2 +5,6 @@ # bunyan Changelog

## 1.0.6
- Fixing special values (eg, 'hourly') for period rollover. These were broken in v1.0.5
## 1.0.5

@@ -7,0 +11,0 @@

@@ -171,2 +171,4 @@ 'use strict';

base.emit('newfile', { stream: stream, path: streamPath });
if (next) {

@@ -173,0 +175,0 @@ next();

@@ -5,4 +5,6 @@ 'use strict';

var _ = require('lodash');
var EventEmitter = require('events').EventEmitter;
function LimitedQueue(worker) {
var base = new EventEmitter();

@@ -42,2 +44,4 @@ const maxQueueLength = 10000;

throwLogsAway = false;
base.emit('caughtup');
}

@@ -75,2 +79,4 @@

throwLogsAway = true;
base.emit('losingdata');
} else {

@@ -97,2 +103,4 @@ queue.push(s);

throwLogsAway = false;
base.emit('caughtup');
}

@@ -110,5 +118,5 @@ }

resume: queue.resume
});
}, base);
}
module.exports = LimitedQueue;

4

lib/optionParser.js

@@ -26,3 +26,3 @@ 'use strict';

// 'monthly' (1m) and 'yearly' (1y)
var availableperiods = {
var crackedperiod = {
'hourly': '1h',

@@ -34,3 +34,3 @@ 'daily': '1d',

}[period] || period;
var m = /^([1-9][0-9]*)([hdwmy]|ms)$/.exec(period);
var m = /^([1-9][0-9]*)([hdwmy]|ms)$/.exec(crackedperiod);
if (!m) {

@@ -37,0 +37,0 @@ throw new Error('invalid period: "' + period + '"');

@@ -52,2 +52,11 @@ // A rotating file stream will just

writeQueue.pause();
writeQueue.on('losingdata', function () {
base.emit('losingdata');
});
writeQueue.on('caughtup', function () {
base.emit('caughtup');
});
rotator.initialise(function (err, newstream, filePath) {

@@ -58,8 +67,14 @@ if (err) {

stream = newstream;
base.emit('newfile', {path: filePath});
writeQueue.resume();
});
rotator.on('error', function (err) {
base.emit('error', err);
});
rotator.on('newfile', function (newfile) {
stream = newfile.stream;
base.emit('newfile', { path: newfile.path });
});
function rotate() {

@@ -77,5 +92,2 @@ if (writeQueue.paused()) {

stream = newstream;
base.emit('newfile', {path: filePath});
writeQueue.resume();

@@ -82,0 +94,0 @@ });

{
"name": "bunyan-rotating-file-stream",
"version": "1.0.5",
"version": "1.0.6",
"description": "a rotating file stream for the bunyan logging system",

@@ -5,0 +5,0 @@ "author": "Jim Tupper <npm@tupper.org.uk> (http://github.com/rcomian)",

@@ -10,3 +10,3 @@ var bunyan = require('bunyan');

function runTest(options, next) {
function runTest(name, options, next) {
var rfs = RotatingFileStream(_.extend({}, { path: 'foo.log' }, options.stream));

@@ -22,3 +22,9 @@

rfs.on('losingdata', function () {
if (ia) clearInterval(ia);
if (maintimer) clearTimeout(maintimer);
next('Losing data - abandon test: ' + name);
});
var i = 0;

@@ -34,2 +40,3 @@ var batch = _.extend({}, { size: 8 }, options.batch);

clearInterval(ia);
ia = null;
rfs.destroy();

@@ -42,4 +49,6 @@ next();

var maintimer = null;
if (typeof (batch.duration) !== 'undefined') {
setTimeout(function ()
maintimer = setTimeout(function ()
{

@@ -70,3 +79,3 @@ clearInterval(ia);

function (next) { fx.mkdir(name, next); },
function (next) { runTest ({
function (next) { runTest (name, {
stream: { path: name + '/test.log', threshold: '1m' },

@@ -91,3 +100,3 @@ batch: { iterations: 100000 }

function (next) { fx.mkdir(name, next); },
function (next) { runTest ({
function (next) { runTest (name, {
stream: { path: name + '/test.log', period: '1000ms' },

@@ -112,3 +121,3 @@ batch: { duration: 9500 }

function (next) { fx.mkdir(name, next); },
function (next) { runTest ({
function (next) { runTest (name, {
stream: { path: name + '/test.log', threshold: '1m', gzip: true },

@@ -134,3 +143,3 @@ batch: { iterations: 100000 }

function (next) { fx.mkdir(name, next); },
function (next) { runTest ({
function (next) { runTest (name, {
stream: { path: name + '/test.log', threshold: '1m', totalSize: '10m' },

@@ -155,3 +164,3 @@ batch: { iterations: 100000 }

function (next) { fx.mkdir(name, next); },
function (next) { runTest ({
function (next) { runTest (name, {
stream: { path: name + '/test.log', threshold: '1m', totalFiles: 5 },

@@ -170,3 +179,23 @@ batch: { iterations: 100000 }

function shorthandperiod(next) {
var name = 'testlogs/' + 'shorthandperiod';
async.series([
function (next) { rmdir(name, ignoreMissing(next)); },
function (next) { fx.mkdir(name, next); },
function (next) { runTest (name, {
stream: { path: name + '/test.log', period: 'hourly'},
batch: { iterations: 100 }
}, next); },
function (next) {
var files = fs.readdirSync(name);
assert.equal(1, files.length);
console.log(name, 'passed');
next();
},
function (next) { rmdir(name, next); }
], next);
}
async.parallel([

@@ -178,4 +207,5 @@ basicthreshold,

totalfiles,
shorthandperiod
], function (err) {
if (err) console.log(err);
});
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc