From d03fcf6d6c7a5532f6ab807a32cc155f2b71a832 Mon Sep 17 00:00:00 2001 From: nimrod-becker Date: Wed, 11 Mar 2015 13:42:15 +0200 Subject: [PATCH 1/3] Issue #556 maxFiles doesn't seem to behave as expected --- lib/winston/transports/file.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/winston/transports/file.js b/lib/winston/transports/file.js index 014fec278..bc1438687 100644 --- a/lib/winston/transports/file.js +++ b/lib/winston/transports/file.js @@ -555,7 +555,7 @@ File.prototype._checkMaxFilesIncrementing = function (ext, basename, callback) { } oldest = this._created - this.maxFiles; - target = path.join(this.dirname, basename + (oldest === 0 ? oldest : '') + ext); + target = path.join(this.dirname, basename + (oldest !== 0 ? oldest : '') + ext); fs.unlink(target, callback); }; From 798262b1bfb120654f655f4c7d83d3180091a1be Mon Sep 17 00:00:00 2001 From: nimrod-becker Date: Wed, 11 Mar 2015 20:04:49 +0200 Subject: [PATCH 2/3] fix maxfiles test --- test/transports/file-maxfiles-test.js | 34 +++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/test/transports/file-maxfiles-test.js b/test/transports/file-maxfiles-test.js index a9fa89e8c..7634e2857 100644 --- a/test/transports/file-maxfiles-test.js +++ b/test/transports/file-maxfiles-test.js @@ -23,7 +23,7 @@ var maxfilesTransport = new winston.transports.File({ maxsize: 4096, maxFiles: 3 }); - + vows.describe('winston/transports/file/maxfiles').addBatch({ "An instance of the File Transport": { "when passed a valid filename": { @@ -43,48 +43,48 @@ vows.describe('winston/transports/file/maxfiles').addBatch({ topic: function () { var that = this, created = 0; - + function data(ch) { return new Array(1018).join(String.fromCharCode(65 + ch)); }; - + function logKbytes(kbytes, txt) { // // With no timestamp and at the info level, - // winston adds exactly 7 characters: + // winston adds exactly 7 characters: // [info](4)[ :](2)[\n](1) // for (var i = 0; i < kbytes; i++) { maxfilesTransport.log('info', data(txt), null, function () { }); } } - + maxfilesTransport.on('logged', function () { if (++created === 6) { return that.callback(); } - + logKbytes(4, created); }); - + logKbytes(4, created); }, "should be only 3 files called 5.log, 4.log and 3.log": function () { for (var num = 0; num < 6; num++) { var file = !num ? 'testmaxfiles.log' : 'testmaxfiles' + num + '.log', fullpath = path.join(__dirname, '..', 'fixtures', 'logs', file); - + // There should be no files with that name if (num >= 0 && num < 3) { - return assert.throws(function () { - fs.statSync(file); + assert.throws(function () { + fs.statSync(fullpath); }, Error); - } - - // The other files should be exist - assert.doesNotThrow(function () { - fs.statSync(file); - }, Error); + } else { + // The other files should be exist + assert.doesNotThrow(function () { + fs.statSync(fullpath); + }, Error); + } } }, "should have the correct content": function () { @@ -99,4 +99,4 @@ vows.describe('winston/transports/file/maxfiles').addBatch({ } } } -}).export(module); \ No newline at end of file +}).export(module); From a300bbec7c359cf62aba22083d964ae4475d3677 Mon Sep 17 00:00:00 2001 From: nimrod-becker Date: Thu, 12 Mar 2015 08:43:11 +0200 Subject: [PATCH 3/3] indent --- test/transports/file-maxfiles-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/transports/file-maxfiles-test.js b/test/transports/file-maxfiles-test.js index 7634e2857..62564a24e 100644 --- a/test/transports/file-maxfiles-test.js +++ b/test/transports/file-maxfiles-test.js @@ -82,7 +82,7 @@ vows.describe('winston/transports/file/maxfiles').addBatch({ } else { // The other files should be exist assert.doesNotThrow(function () { - fs.statSync(fullpath); + fs.statSync(fullpath); }, Error); } }