mirror of
https://github.com/log4js-node/log4js-node.git
synced 2025-12-08 19:26:01 +00:00
Merge pull request #889 from log4js-node/datefile-maxlogsize-to-maxsize
fix(#887): map maxLogSize to maxSize
This commit is contained in:
commit
eccf09d425
@ -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,
|
||||
|
||||
@ -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();
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user