bunyan-rotating-file-stream
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -5,2 +5,7 @@ # bunyan Changelog | ||
## 1.1.1 | ||
- Being far more aggressive when writing logs in order to improve log writing speed | ||
- Basic performance test that writes 1million logs | ||
## 1.1.0 | ||
@@ -7,0 +12,0 @@ |
@@ -14,4 +14,6 @@ 'use strict'; | ||
var queue = async.queue(function (s, callback) { | ||
var joiners = []; // List of callbacks to call when we're empty | ||
var queue = async.cargo(function (s, callback) { | ||
var queueLowerThreshold = (maxQueueLength * queueClearingThreshold); | ||
@@ -104,2 +106,10 @@ if (throwLogsAway && queue.length() < queueLowerThreshold) { | ||
} | ||
if (joiners.length > 0) { | ||
for (var i = 0; i < joiners.length; i += 1) { | ||
joiners[i](); | ||
} | ||
joiners = []; | ||
} | ||
} | ||
@@ -111,2 +121,10 @@ | ||
function join(cb) { | ||
if (queue.length() === 0) { | ||
cb(); | ||
} else { | ||
joiners.push(cb); | ||
} | ||
} | ||
return _.extend({}, { | ||
@@ -116,3 +134,4 @@ push, | ||
pause: queue.pause, | ||
resume: queue.resume | ||
resume: queue.resume, | ||
join | ||
}, base); | ||
@@ -119,0 +138,0 @@ } |
@@ -35,12 +35,17 @@ // A rotating file stream will just | ||
function writer(s, callback) { | ||
var str = JSON.stringify(s, bunyan.safeCycles()) + '\n'; | ||
function writer(logs, callback) { | ||
for (var i = 0; i < logs.length; i += 1) { | ||
var str = JSON.stringify(logs[i], bunyan.safeCycles()) + '\n'; | ||
stream.write(str, function (err) { | ||
if (err) { | ||
base.emit('error', err); | ||
} else { | ||
base.emit('data', { bytesWritten: stream.bytesWritten }); | ||
} | ||
stream.write(str, function (err) { | ||
if (err) { | ||
base.emit('error', err); | ||
} else { | ||
base.emit('data', { bytesWritten: stream.bytesWritten }); | ||
} | ||
}); | ||
} | ||
process.nextTick(function () { | ||
callback(); | ||
@@ -107,3 +112,5 @@ }); | ||
writeQueue.pause(); | ||
stream.destroy(); | ||
if (stream) { | ||
stream.destroy(); | ||
} | ||
base.emit('shutdown'); | ||
@@ -114,6 +121,12 @@ }; | ||
writeQueue.pause(); | ||
stream.destroySoon(); | ||
if (stream) { | ||
stream.destroy(); | ||
} | ||
base.emit('shutdown'); | ||
}; | ||
function join(cb) { | ||
writeQueue.join(cb); | ||
} | ||
return _.extend({}, { | ||
@@ -126,3 +139,4 @@ stream, | ||
destroy, | ||
destroySoon | ||
destroySoon, | ||
join | ||
}, base); | ||
@@ -129,0 +143,0 @@ } |
{ | ||
"name": "bunyan-rotating-file-stream", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"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)", |
@@ -31,3 +31,3 @@ var bunyan = require('bunyan'); | ||
var i = 0; | ||
var batch = _.extend({}, { size: 8 }, options.batch); | ||
var batch = _.extend({}, { size: 100 }, options.batch); | ||
@@ -42,4 +42,6 @@ var ia = setInterval(function () { | ||
ia = null; | ||
rfs.destroy(); | ||
next(); | ||
rfs.join(function () { | ||
rfs.destroy(); | ||
next(); | ||
}); | ||
return; | ||
@@ -46,0 +48,0 @@ } |
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
54342
23
1027
6