Merge pull request #889 from log4js-node/datefile-maxlogsize-to-maxsize

fix(#887): map maxLogSize to maxSize
This commit is contained in:
Gareth Jones 2019-05-29 08:40:18 +10:00 committed by GitHub
commit eccf09d425
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View File

@ -20,6 +20,10 @@ function appender(
options,
timezoneOffset
) {
// the options for file appender use maxLogSize, but the docs say any file appender
// options should work for dateFile as well.
options.maxSize = options.maxLogSize;
const logFile = new streams.DateRollingFileStream(
filename,
pattern,

View File

@ -5,6 +5,7 @@ const path = require('path');
const fs = require('fs');
const EOL = require('os').EOL || '\n';
const format = require('date-format');
const sandbox = require('@log4js-node/sandboxed-module');
const log4js = require('../../lib/log4js');
function removeFile(filename) {
@ -133,5 +134,26 @@ test('../../lib/appenders/dateFile', (batch) => {
});
});
batch.test('should map maxLogSize to maxSize', (t) => {
const fakeStreamroller = {};
class DateRollingFileStream {
constructor(filename, pattern, options) {
fakeStreamroller.filename = filename;
fakeStreamroller.pattern = pattern;
fakeStreamroller.options = options;
}
}
fakeStreamroller.DateRollingFileStream = DateRollingFileStream;
const dateFileAppenderModule = sandbox.require('../../lib/appenders/dateFile', {
requires: { streamroller: fakeStreamroller }
});
dateFileAppenderModule.configure({
filename: 'cheese.log', pattern: 'yyyy', maxLogSize: 100
}, { basicLayout: () => {} });
t.equal(fakeStreamroller.options.maxSize, 100);
t.end();
});
batch.end();
});