Merge pull request #794 from so5/multiFile

fix: #793
This commit is contained in:
Gareth Jones 2018-10-09 07:27:43 +11:00 committed by GitHub
commit 0700d6a94e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -60,6 +60,9 @@ module.exports.configure = (config, layouts) => {
appender.shutdown = (cb) => {
let shutdownFunctions = files.size;
if (shutdownFunctions <= 0) {
cb();
}
let error;
timers.forEach((timer) => {
clearInterval(timer.interval);

View File

@ -162,5 +162,24 @@ test('multiFile appender', (batch) => {
});
});
batch.test('should shutdown safely even if it is not used', (t) => {
log4js.configure({
appenders: {
out: { type: 'stdout' },
test: {
type: 'multiFile', base: 'logs/', property: 'categoryName', extension: '.log'
}
},
categories: {
default: { appenders: ['out'], level: 'info' },
test: { appenders: ['test'], level: 'debug' }
}
});
log4js.shutdown(() => {
t.ok('callback is called');
t.end();
});
});
batch.end();
});