bunyan-rotating-file-stream
Advanced tools
Comparing version 1.5.2 to 1.5.3
# bunyan Changelog | ||
## 1.5.3 | ||
- Fixed issue with handling template filenames containing dots: #4 | ||
- Can handle this.%Y.log as well as this.%N-%Y.log, which both failed before, when using gzip. | ||
## 1.5.2 | ||
@@ -4,0 +10,0 @@ |
@@ -26,2 +26,10 @@ var fs = require('fs'); | ||
function removeN(originalName) { | ||
return originalName | ||
.replace('.%N', '') | ||
.replace('_%N', '') | ||
.replace('-%N', '') | ||
.replace('%N', ''); | ||
} | ||
function filterJustOurLogFiles(includeZipFiles) { | ||
@@ -39,4 +47,15 @@ return function (files, next) { | ||
var prefix = parsedPath.name.split('%').slice(0, 1).join(''); | ||
var prefixes = []; | ||
var parts = parsedPath.name.split('%'); | ||
prefixes.push(parts.slice(0, 1).join('')); | ||
if (parts.slice(1,2).join('').slice(0,1) === 'N') { | ||
// First substitution part is %N, which might not be used | ||
// Need to check the prefix when %N isn't used | ||
var altname = removeN(parsedPath.name); | ||
parts = altname.split('%'); | ||
prefixes.push(parts.slice(0, 1).join('')); | ||
} | ||
if (includeZipFiles && parsedFile.ext === '.gz') { | ||
@@ -50,6 +69,6 @@ var splitname = parsedFile.name.split('.'); | ||
parsedFile.name = splitname.slice(0, -1).join(''); | ||
parsedFile.name = splitname.slice(0, -1).join('.'); | ||
} | ||
return (parsedFile.name.indexOf(prefix) === 0 && | ||
return (_.some(prefixes, function (prefix) { return parsedFile.name.indexOf(prefix) === 0; }) && | ||
parsedFile.ext === parsedPath.ext); | ||
@@ -159,7 +178,3 @@ }); | ||
if (nonce === 0) { | ||
result.name = result.name | ||
.replace('.%N', '') | ||
.replace('_%N', '') | ||
.replace('-%N', '') | ||
.replace('%N', ''); | ||
result.name = removeN(result.name); | ||
} else if (result.name.indexOf('%N') >= 0) { | ||
@@ -166,0 +181,0 @@ result.name = result.name.replace('%N', String(nonce)); |
@@ -42,2 +42,6 @@ 'use strict'; | ||
fs.createReadStream(unzippedPath) | ||
.on('error', function (err) { | ||
base.emit('error', err); | ||
next(); | ||
}) | ||
.pipe(zlib.createGzip()) | ||
@@ -48,5 +52,2 @@ .pipe(fs.createWriteStream(zippedPath)) | ||
}) | ||
.on('error', function (err) { | ||
base.emit('error', err); | ||
}); | ||
} | ||
@@ -53,0 +54,0 @@ |
@@ -85,2 +85,4 @@ 'use strict'; | ||
} | ||
return queue.length(); | ||
} | ||
@@ -139,3 +141,4 @@ | ||
join: join, | ||
isEmpty: isEmpty | ||
isEmpty: isEmpty, | ||
length: queue.length | ||
}, base); | ||
@@ -142,0 +145,0 @@ } |
@@ -114,2 +114,3 @@ /* global Buffer */ | ||
var written = -1; // the index of the last successful write | ||
var bytesWritten = 0; // Bytes written to the stream this batch | ||
for (var i = 0; stream && i < logs.length; i += 1) { | ||
@@ -130,2 +131,4 @@ var log = options.map(logs[i]); | ||
bytesWritten += writeBuffer.length; | ||
if (stream) { | ||
@@ -154,2 +157,4 @@ try { | ||
nextTick(callback); | ||
base.emit('perf-writebatch', bytesWritten, written + 1, writeQueue.length()); | ||
} | ||
@@ -194,2 +199,3 @@ | ||
function rotateActual(triggerinfo) { | ||
var rotateStart = Date.now(); | ||
@@ -204,2 +210,4 @@ rotateFunction = function () {}; | ||
rotateFunction = rotateActual; | ||
base.emit('perf-rotation', Date.now() - rotateStart); | ||
}); | ||
@@ -215,3 +223,4 @@ } | ||
function write(s, callback) { | ||
writeQueue.push(s, callback); | ||
var length = writeQueue.push(s, callback); | ||
base.emit('perf-queued', length); | ||
} | ||
@@ -218,0 +227,0 @@ |
{ | ||
"name": "bunyan-rotating-file-stream", | ||
"version": "1.5.2", | ||
"version": "1.5.3", | ||
"description": "a rotating file stream for the bunyan logging system", | ||
@@ -25,2 +25,3 @@ "author": "Jim Tupper <npm@tupper.org.uk> (http://github.com/rcomian)", | ||
"devDependencies": { | ||
"logzio-nodejs": "logzio/logzio-nodejs", | ||
"bunyan": "^1.7.1", | ||
@@ -27,0 +28,0 @@ "js-combinatorics": "^0.5.0", |
Sorry, the diff of this file is not supported yet
3324
188154
7
33