Merge pull request #840 from martinheidegger/update-dependencies

Updating dependencies (including eslint)
This commit is contained in:
Gareth Jones 2019-02-21 09:43:15 +11:00 committed by GitHub
commit 675dfd9642
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 1848 additions and 3254 deletions

View File

@ -1,5 +1,6 @@
'use strict';
// eslint-disable-next-line no-console
const consoleLog = console.log.bind(console);
function consoleAppender(layout, timezoneOffset) {

View File

@ -71,7 +71,8 @@ class RollingFileSync {
function byIndex(a, b) {
if (index(a) > index(b)) {
return 1;
} else if (index(a) < index(b)) {
}
if (index(a) < index(b)) {
return -1;
}

View File

@ -31,11 +31,11 @@ const tryLoading = (modulePath, config) => {
}
};
const loadAppenderModule = (type, config) => coreAppenders.get(type) ||
tryLoading(`./${type}`, config) ||
tryLoading(type, config) ||
(require.main && tryLoading(path.join(path.dirname(require.main.filename), type), config)) ||
tryLoading(path.join(process.cwd(), type), config);
const loadAppenderModule = (type, config) => coreAppenders.get(type)
|| tryLoading(`./${type}`, config)
|| tryLoading(type, config)
|| (require.main && tryLoading(path.join(path.dirname(require.main.filename), type), config))
|| tryLoading(path.join(process.cwd(), type), config);
const createAppender = (name, config) => {
const appenderConfig = config.appenders[name];

View File

@ -27,8 +27,8 @@ function noLogFilter(filters, appender) {
}
filters = removeNullOrEmptyRegexp(filters);
const regex = new RegExp(filters.join('|'), 'i');
if (filters.length === 0 ||
logEvent.data.findIndex(value => regex.test(value)) < 0) {
if (filters.length === 0
|| logEvent.data.findIndex(value => regex.test(value)) < 0) {
debug('Not excluded, sending to appender');
appender(logEvent);
}

View File

@ -1,7 +1,7 @@
const debug = require('debug')('log4js:categories');
const configuration = require('./configuration');
const levels = require('./levels');
const appenders = require('./appenders');
const debug = require('debug')('log4js:categories');
const categories = new Map();
@ -53,8 +53,8 @@ configuration.addListener((config) => {
configuration.throwExceptionIf(
config,
configuration.not(levels.getLevel(category.level)),
`category "${name}" is not valid (level "${category.level}" not recognised;` +
` valid levels are ${levels.levels.join(', ')})`
`category "${name}" is not valid (level "${category.level}" not recognised;`
+ ` valid levels are ${levels.levels.join(', ')})`
);
});
@ -108,8 +108,8 @@ const setLevelForCategory = (category, level) => {
debug(`setLevelForCategory: found ${categoryConfig} for ${category}`);
if (!categoryConfig) {
const sourceCategoryConfig = configForCategory(category);
debug('setLevelForCategory: no config found for category, ' +
`found ${sourceCategoryConfig} for parents of ${category}`);
debug('setLevelForCategory: no config found for category, '
+ `found ${sourceCategoryConfig} for parents of ${category}`);
categoryConfig = { appenders: sourceCategoryConfig.appenders };
}
categoryConfig.level = level;

View File

@ -1,7 +1,7 @@
const cluster = require('cluster');
const debug = require('debug')('log4js:clustering');
const LoggingEvent = require('./LoggingEvent');
const configuration = require('./configuration');
const cluster = require('cluster');
const listeners = [];

View File

@ -22,8 +22,8 @@ const throwExceptionIf = (config, checks, message) => {
const tests = Array.isArray(checks) ? checks : [checks];
tests.forEach((test) => {
if (test) {
throw new Error(`Problem with log4js configuration: (${util.inspect(config, { depth: 5 })})` +
` - ${message}`);
throw new Error(`Problem with log4js configuration: (${util.inspect(config, { depth: 5 })})`
+ ` - ${message}`);
}
});
};

View File

@ -4,21 +4,20 @@
const levels = require('./levels');
const DEFAULT_FORMAT = ':remote-addr - -' +
' ":method :url HTTP/:http-version"' +
' :status :content-length ":referrer"' +
' ":user-agent"';
/**
* Return request url path,
* adding this function prevents the Cyclomatic Complexity,
* for the assemble_tokens function at low, to pass the tests.
*
* @param {IncomingMessage} req
* @return {String}
* @api private
*/
const DEFAULT_FORMAT = ':remote-addr - -'
+ ' ":method :url HTTP/:http-version"'
+ ' :status :content-length ":referrer"'
+ ' ":user-agent"';
/**
* Return request url path,
* adding this function prevents the Cyclomatic Complexity,
* for the assemble_tokens function at low, to pass the tests.
*
* @param {IncomingMessage} req
* @return {String}
* @api private
*/
function getUrl(req) {
return req.originalUrl || req.url;
}
@ -67,21 +66,21 @@ function assembleTokens(req, res, customTokens) {
});
defaultTokens.push({
token: ':remote-addr',
replacement: req.headers['x-forwarded-for'] ||
req.ip ||
req._remoteAddress ||
(req.socket &&
(req.socket.remoteAddress ||
(req.socket.socket && req.socket.socket.remoteAddress)
replacement: req.headers['x-forwarded-for']
|| req.ip
|| req._remoteAddress
|| (req.socket
&& (req.socket.remoteAddress
|| (req.socket.socket && req.socket.socket.remoteAddress)
)
)
});
defaultTokens.push({ token: ':user-agent', replacement: req.headers['user-agent'] });
defaultTokens.push({
token: ':content-length',
replacement: res.getHeader('content-length') ||
(res.__headers && res.__headers['Content-Length']) ||
'-'
replacement: res.getHeader('content-length')
|| (res.__headers && res.__headers['Content-Length'])
|| '-'
});
defaultTokens.push({
token: /:req\[([^\]]+)]/g,

View File

@ -43,12 +43,12 @@ function colorize(str, style) {
function timestampLevelAndCategory(loggingEvent, colour) {
return colorize(
util.format(
'[%s] [%s] %s - '
, dateFormat.asString(loggingEvent.startTime)
, loggingEvent.level
, loggingEvent.categoryName
)
, colour
'[%s] [%s] %s - ',
dateFormat.asString(loggingEvent.startTime),
loggingEvent.level,
loggingEvent.categoryName
),
colour
);
}

View File

@ -65,6 +65,7 @@ function configure(configurationFileOrObject) {
enabled = true;
// eslint-disable-next-line no-use-before-define
return log4js;
}

4729
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -43,7 +43,7 @@
},
"dependencies": {
"date-format": "^2.0.0",
"debug": "^3.1.0",
"debug": "^4.1.1",
"flatted": "^2.0.0",
"rfdc": "^1.1.2",
"streamroller": "^1.0.1"
@ -51,16 +51,16 @@
"devDependencies": {
"@log4js-node/sandboxed-module": "^2.2.0",
"codecov": "^3.0.2",
"conventional-changelog": "^1.1.24",
"conventional-changelog": "^3.0.6",
"deep-freeze": "0.0.1",
"eslint": "^4.19.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint": "^5.14.1",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-import-resolver-node": "^0.3.1",
"eslint-plugin-import": "^2.11.0",
"husky": "^0.14.3",
"nyc": "^11.7.3",
"tap": "^11.1.5",
"typescript": "^2.8.3",
"husky": "^1.3.1",
"nyc": "^13.3.0",
"tap": "^12.5.3",
"typescript": "^3.3.3",
"validate-commit-msg": "^2.14.0"
},
"browser": {

View File

@ -4,10 +4,10 @@ const test = require('tap').test;
const util = require('util');
const path = require('path');
const sandbox = require('@log4js-node/sandboxed-module');
const log4js = require('../../lib/log4js');
const configuration = require('../../lib/configuration');
const debug = require('debug')('log4js:test.configuration-validation');
const deepFreeze = require('deep-freeze');
const log4js = require('../../lib/log4js');
const configuration = require('../../lib/configuration');
const testAppender = (label, result) => ({
configure: function (config, layouts, findAppender) {
@ -25,8 +25,9 @@ const testAppender = (label, result) => ({
test('log4js configuration validation', (batch) => {
batch.test('should give error if config is just plain silly', (t) => {
[null, undefined, '', ' ', []].forEach((config) => {
const expectedError =
new Error(`Problem with log4js configuration: (${util.inspect(config)}) - must be an object.`);
const expectedError = new Error(
`Problem with log4js configuration: (${util.inspect(config)}) - must be an object.`
);
t.throws(
() => configuration.configure(config),
expectedError
@ -37,32 +38,36 @@ test('log4js configuration validation', (batch) => {
});
batch.test('should give error if config is an empty object', (t) => {
const expectedError =
new Error('Problem with log4js configuration: ({}) - must have a property "appenders" of type object.');
const expectedError = new Error(
'Problem with log4js configuration: ({}) - must have a property "appenders" of type object.'
);
t.throws(() => log4js.configure({}), expectedError);
t.end();
});
batch.test('should give error if config has no appenders', (t) => {
const expectedError =
new Error('Problem with log4js configuration: ({ categories: {} }) ' +
'- must have a property "appenders" of type object.');
const expectedError = new Error(
'Problem with log4js configuration: ({ categories: {} }) '
+ '- must have a property "appenders" of type object.'
);
t.throws(() => log4js.configure({ categories: {} }), expectedError);
t.end();
});
batch.test('should give error if config has no categories', (t) => {
const expectedError =
new Error('Problem with log4js configuration: ({ appenders: { out: { type: \'stdout\' } } }) ' +
'- must have a property "categories" of type object.');
const expectedError = new Error(
'Problem with log4js configuration: ({ appenders: { out: { type: \'stdout\' } } }) '
+ '- must have a property "categories" of type object.'
);
t.throws(() => log4js.configure({ appenders: { out: { type: 'stdout' } } }), expectedError);
t.end();
});
batch.test('should give error if appenders is not an object', (t) => {
const error =
new Error('Problem with log4js configuration: ({ appenders: [], categories: [] })' +
' - must have a property "appenders" of type object.');
const error = new Error(
'Problem with log4js configuration: ({ appenders: [], categories: [] })'
+ ' - must have a property "appenders" of type object.'
);
t.throws(
() => log4js.configure({ appenders: [], categories: [] }),
error
@ -71,9 +76,10 @@ test('log4js configuration validation', (batch) => {
});
batch.test('should give error if appenders are not all valid', (t) => {
const error =
new Error('Problem with log4js configuration: ({ appenders: { thing: \'cheese\' }, categories: {} })' +
' - appender "thing" is not valid (must be an object with property "type")');
const error = new Error(
'Problem with log4js configuration: ({ appenders: { thing: \'cheese\' }, categories: {} })'
+ ' - appender "thing" is not valid (must be an object with property "type")'
);
t.throws(
() => log4js.configure({ appenders: { thing: 'cheese' }, categories: {} }),
error
@ -82,8 +88,10 @@ test('log4js configuration validation', (batch) => {
});
batch.test('should require at least one appender', (t) => {
const error = new Error('Problem with log4js configuration: ({ appenders: {}, categories: {} })' +
' - must define at least one appender.');
const error = new Error(
'Problem with log4js configuration: ({ appenders: {}, categories: {} })'
+ ' - must define at least one appender.'
);
t.throws(
() => log4js.configure({ appenders: {}, categories: {} }),
error
@ -92,9 +100,11 @@ test('log4js configuration validation', (batch) => {
});
batch.test('should give error if categories are not all valid', (t) => {
const error = new Error('Problem with log4js configuration: ' +
'({ appenders: { stdout: { type: \'stdout\' } },\n categories: { thing: \'cheese\' } })' +
' - category "thing" is not valid (must be an object with properties "appenders" and "level")');
const error = new Error(
'Problem with log4js configuration: '
+ '({ appenders: { stdout: { type: \'stdout\' } },\n categories: { thing: \'cheese\' } })'
+ ' - category "thing" is not valid (must be an object with properties "appenders" and "level")'
);
t.throws(
() => log4js.configure({ appenders: { stdout: { type: 'stdout' } }, categories: { thing: 'cheese' } }),
error
@ -103,10 +113,12 @@ test('log4js configuration validation', (batch) => {
});
batch.test('should give error if default category not defined', (t) => {
const error = new Error('Problem with log4js configuration: ' +
'({ appenders: { stdout: { type: \'stdout\' } },\n' +
' categories: { thing: { appenders: [ \'stdout\' ], level: \'ERROR\' } } })' +
' - must define a "default" category.');
const error = new Error(
'Problem with log4js configuration: '
+ '({ appenders: { stdout: { type: \'stdout\' } },\n'
+ ' categories: { thing: { appenders: [ \'stdout\' ], level: \'ERROR\' } } })'
+ ' - must define a "default" category.'
);
t.throws(
() => log4js.configure({
appenders: { stdout: { type: 'stdout' } },
@ -118,9 +130,10 @@ test('log4js configuration validation', (batch) => {
});
batch.test('should require at least one category', (t) => {
const error =
new Error('Problem with log4js configuration: ({ appenders: { stdout: { type: \'stdout\' } }, categories: {} })' +
' - must define at least one category.');
const error = new Error(
'Problem with log4js configuration: ({ appenders: { stdout: { type: \'stdout\' } }, categories: {} })'
+ ' - must define at least one category.'
);
t.throws(
() => log4js.configure({ appenders: { stdout: { type: 'stdout' } }, categories: {} }),
error
@ -129,10 +142,12 @@ test('log4js configuration validation', (batch) => {
});
batch.test('should give error if category.appenders is not an array', (t) => {
const error = new Error('Problem with log4js configuration: ' +
'({ appenders: { stdout: { type: \'stdout\' } },\n' +
' categories: { thing: { appenders: {}, level: \'ERROR\' } } })' +
' - category "thing" is not valid (appenders must be an array of appender names)');
const error = new Error(
'Problem with log4js configuration: '
+ '({ appenders: { stdout: { type: \'stdout\' } },\n'
+ ' categories: { thing: { appenders: {}, level: \'ERROR\' } } })'
+ ' - category "thing" is not valid (appenders must be an array of appender names)'
);
t.throws(
() => log4js.configure({
appenders: { stdout: { type: 'stdout' } },
@ -144,10 +159,12 @@ test('log4js configuration validation', (batch) => {
});
batch.test('should give error if category.appenders is empty', (t) => {
const error = new Error('Problem with log4js configuration: ' +
'({ appenders: { stdout: { type: \'stdout\' } },\n' +
' categories: { thing: { appenders: [], level: \'ERROR\' } } })' +
' - category "thing" is not valid (appenders must contain at least one appender name)');
const error = new Error(
'Problem with log4js configuration: '
+ '({ appenders: { stdout: { type: \'stdout\' } },\n'
+ ' categories: { thing: { appenders: [], level: \'ERROR\' } } })'
+ ' - category "thing" is not valid (appenders must contain at least one appender name)'
);
t.throws(
() => log4js.configure({
appenders: { stdout: { type: 'stdout' } },
@ -159,10 +176,12 @@ test('log4js configuration validation', (batch) => {
});
batch.test('should give error if categories do not refer to valid appenders', (t) => {
const error = new Error('Problem with log4js configuration: ' +
'({ appenders: { stdout: { type: \'stdout\' } },\n' +
' categories: { thing: { appenders: [ \'cheese\' ], level: \'ERROR\' } } })' +
' - category "thing" is not valid (appender "cheese" is not defined)');
const error = new Error(
'Problem with log4js configuration: '
+ '({ appenders: { stdout: { type: \'stdout\' } },\n'
+ ' categories: { thing: { appenders: [ \'cheese\' ], level: \'ERROR\' } } })'
+ ' - category "thing" is not valid (appender "cheese" is not defined)'
);
t.throws(
() => log4js.configure({
appenders: { stdout: { type: 'stdout' } },
@ -174,11 +193,13 @@ test('log4js configuration validation', (batch) => {
});
batch.test('should give error if category level is not valid', (t) => {
const error = new Error('Problem with log4js configuration: ' +
'({ appenders: { stdout: { type: \'stdout\' } },\n' +
' categories: { default: { appenders: [ \'stdout\' ], level: \'Biscuits\' } } })' +
' - category "default" is not valid (level "Biscuits" not recognised; ' +
'valid levels are ALL, TRACE, DEBUG, INFO, WARN, ERROR, FATAL, MARK, OFF)');
const error = new Error(
'Problem with log4js configuration: '
+ '({ appenders: { stdout: { type: \'stdout\' } },\n'
+ ' categories: { default: { appenders: [ \'stdout\' ], level: \'Biscuits\' } } })'
+ ' - category "default" is not valid (level "Biscuits" not recognised; '
+ 'valid levels are ALL, TRACE, DEBUG, INFO, WARN, ERROR, FATAL, MARK, OFF)'
);
t.throws(
() => log4js.configure({
appenders: { stdout: { type: 'stdout' } },
@ -190,10 +211,12 @@ test('log4js configuration validation', (batch) => {
});
batch.test('should give error if appender type cannot be found', (t) => {
const error = new Error('Problem with log4js configuration: ' +
'({ appenders: { thing: { type: \'cheese\' } },\n' +
' categories: { default: { appenders: [ \'thing\' ], level: \'ERROR\' } } })' +
' - appender "thing" is not valid (type "cheese" could not be found)');
const error = new Error(
'Problem with log4js configuration: '
+ '({ appenders: { thing: { type: \'cheese\' } },\n'
+ ' categories: { default: { appenders: [ \'thing\' ], level: \'ERROR\' } } })'
+ ' - appender "thing" is not valid (type "cheese" could not be found)'
);
t.throws(
() => log4js.configure({
appenders: { thing: { type: 'cheese' } },

View File

@ -39,6 +39,7 @@ class MockResponse extends EE {
super();
this.cachedHeaders = {};
}
end() {
this.emit('finish');
}

View File

@ -34,6 +34,7 @@ class MockResponse extends EE {
this.statusCode = code;
this.cachedHeaders = {};
}
end() {
this.emit('finish');
}

View File

@ -3,9 +3,9 @@
const test = require('tap').test;
const path = require('path');
const fs = require('fs');
const log4js = require('../../lib/log4js');
const EOL = require('os').EOL || '\n';
const format = require('date-format');
const log4js = require('../../lib/log4js');
function removeFile(filename) {
try {

View File

@ -4,9 +4,9 @@ const test = require('tap').test;
const fs = require('fs');
const path = require('path');
const sandbox = require('@log4js-node/sandboxed-module');
const log4js = require('../../lib/log4js');
const zlib = require('zlib');
const EOL = require('os').EOL || '\n';
const log4js = require('../../lib/log4js');
function removeFile(filename) {
try {

View File

@ -3,8 +3,8 @@
const test = require('tap').test;
const fs = require('fs');
const path = require('path');
const log4js = require('../../lib/log4js');
const EOL = require('os').EOL || '\n';
const log4js = require('../../lib/log4js');
function remove(filename) {
try {

View File

@ -182,8 +182,8 @@ test('log4js layouts', (batch) => {
const output = layout(event);
assert.equal(
output,
'[2010-12-05T14:18:30.045] [DEBUG] tests - this is a test ' +
"{ name: 'Cheese', message: 'Gorgonzola smells.' }"
'[2010-12-05T14:18:30.045] [DEBUG] tests - this is a test '
+ "{ name: 'Cheese', message: 'Gorgonzola smells.' }"
);
assert.end();
});

View File

@ -2,8 +2,8 @@
const test = require('tap').test;
const debug = require('debug')('log4js:test.logger');
const levels = require('../../lib/levels');
const sandbox = require('@log4js-node/sandboxed-module');
const levels = require('../../lib/levels');
const events = [];
const Logger = sandbox.require(

View File

@ -3,8 +3,8 @@
const process = require('process');
const test = require('tap').test;
const debug = require('debug');
const log4js = require('../../lib/log4js');
const fs = require('fs');
const log4js = require('../../lib/log4js');
test('multiFile appender', (batch) => {
batch.test('should write to multiple files based on the loggingEvent property', (t) => {

View File

@ -1,10 +1,10 @@
'use strict';
const test = require('tap').test;
const log4js = require('../../lib/log4js');
const net = require('net');
const childProcess = require('child_process');
const sandbox = require('@log4js-node/sandboxed-module');
const log4js = require('../../lib/log4js');
test('multiprocess appender shutdown (master)', { timeout: 2000 }, (t) => {
log4js.configure({

View File

@ -308,11 +308,10 @@ test('Multiprocess Appender', (batch) => {
}
);
t.throws(
() =>
log4js.configure({
appenders: { master: { type: 'multiprocess', mode: 'master' } },
categories: { default: { appenders: ['master'], level: 'trace' } }
}),
() => log4js.configure({
appenders: { master: { type: 'multiprocess', mode: 'master' } },
categories: { default: { appenders: ['master'], level: 'trace' } }
}),
new Error('multiprocess master must have an "appender" defined')
);
t.end();
@ -330,11 +329,10 @@ test('Multiprocess Appender', (batch) => {
}
);
t.throws(
() =>
log4js.configure({
appenders: { master: { type: 'multiprocess', mode: 'master', appender: 'cheese' } },
categories: { default: { appenders: ['master'], level: 'trace' } }
}),
() => log4js.configure({
appenders: { master: { type: 'multiprocess', mode: 'master', appender: 'cheese' } },
categories: { default: { appenders: ['master'], level: 'trace' } }
}),
new Error('multiprocess master appender "cheese" not defined')
);
t.end();

View File

@ -118,10 +118,12 @@ test('../../lib/logger', (batch) => {
appenders: { stdout: { type: 'stdout' } },
categories: { default: { appenders: ['stdout'], level: 'trace' } }
});
}, new Error('Problem with log4js configuration: ' +
"({ levels: { cheese: { value: 'biscuits' } },\n appenders: { stdout: { type: 'stdout' } },\n" +
" categories: { default: { appenders: [ 'stdout' ], level: 'trace' } } }) - " +
'level "cheese".value must have an integer value'));
}, new Error(
'Problem with log4js configuration: '
+ "({ levels: { cheese: { value: 'biscuits' } },\n appenders: { stdout: { type: 'stdout' } },\n"
+ " categories: { default: { appenders: [ 'stdout' ], level: 'trace' } } }) - "
+ 'level "cheese".value must have an integer value'
));
t.throws(() => {
log4js.configure({
@ -131,10 +133,12 @@ test('../../lib/logger', (batch) => {
appenders: { stdout: { type: 'stdout' } },
categories: { default: { appenders: ['stdout'], level: 'trace' } }
});
}, new Error('Problem with log4js configuration: ' +
"({ levels: { cheese: 'biscuits' },\n appenders: { stdout: { type: 'stdout' } },\n" +
" categories: { default: { appenders: [ 'stdout' ], level: 'trace' } } }) - " +
'level "cheese" must be an object'));
}, new Error(
'Problem with log4js configuration: '
+ "({ levels: { cheese: 'biscuits' },\n appenders: { stdout: { type: 'stdout' } },\n"
+ " categories: { default: { appenders: [ 'stdout' ], level: 'trace' } } }) - "
+ 'level "cheese" must be an object'
));
t.throws(() => {
log4js.configure({
@ -144,10 +148,12 @@ test('../../lib/logger', (batch) => {
appenders: { stdout: { type: 'stdout' } },
categories: { default: { appenders: ['stdout'], level: 'trace' } }
});
}, new Error('Problem with log4js configuration: ' +
"({ levels: { cheese: { thing: 'biscuits' } },\n appenders: { stdout: { type: 'stdout' } },\n" +
" categories: { default: { appenders: [ 'stdout' ], level: 'trace' } } }) - " +
'level "cheese" must have a \'value\' property'));
}, new Error(
'Problem with log4js configuration: '
+ "({ levels: { cheese: { thing: 'biscuits' } },\n appenders: { stdout: { type: 'stdout' } },\n"
+ " categories: { default: { appenders: [ 'stdout' ], level: 'trace' } } }) - "
+ 'level "cheese" must have a \'value\' property'
));
t.throws(() => {
log4js.configure({
@ -157,10 +163,12 @@ test('../../lib/logger', (batch) => {
appenders: { stdout: { type: 'stdout' } },
categories: { default: { appenders: ['stdout'], level: 'trace' } }
});
}, new Error('Problem with log4js configuration: ' +
"({ levels: { cheese: { value: 3 } },\n appenders: { stdout: { type: 'stdout' } },\n" +
" categories: { default: { appenders: [ 'stdout' ], level: 'trace' } } }) - " +
'level "cheese" must have a \'colour\' property'));
}, new Error(
'Problem with log4js configuration: '
+ "({ levels: { cheese: { value: 3 } },\n appenders: { stdout: { type: 'stdout' } },\n"
+ " categories: { default: { appenders: [ 'stdout' ], level: 'trace' } } }) - "
+ 'level "cheese" must have a \'colour\' property'
));
t.throws(() => {
log4js.configure({
@ -170,10 +178,12 @@ test('../../lib/logger', (batch) => {
appenders: { stdout: { type: 'stdout' } },
categories: { default: { appenders: ['stdout'], level: 'trace' } }
});
}, new Error('Problem with log4js configuration: ' +
"({ levels: { cheese: { value: 3, colour: 'pants' } },\n appenders: { stdout: { type: 'stdout' } },\n" +
" categories: { default: { appenders: [ 'stdout' ], level: 'trace' } } }) - " +
'level "cheese".colour must be one of white, grey, black, blue, cyan, green, magenta, red, yellow'));
}, new Error(
'Problem with log4js configuration: '
+ "({ levels: { cheese: { value: 3, colour: 'pants' } },\n appenders: { stdout: { type: 'stdout' } },\n"
+ " categories: { default: { appenders: [ 'stdout' ], level: 'trace' } } }) - "
+ 'level "cheese".colour must be one of white, grey, black, blue, cyan, green, magenta, red, yellow'
));
t.throws(() => {
log4js.configure({
@ -183,10 +193,12 @@ test('../../lib/logger', (batch) => {
appenders: { stdout: { type: 'stdout' } },
categories: { default: { appenders: ['stdout'], level: 'trace' } }
});
}, new Error('Problem with log4js configuration: ' +
"({ levels: { '#pants': 3 },\n appenders: { stdout: { type: 'stdout' } },\n" +
" categories: { default: { appenders: [ 'stdout' ], level: 'trace' } } }) - " +
'level name "#pants" is not a valid identifier (must start with a letter, only contain A-Z,a-z,0-9,_)'));
}, new Error(
'Problem with log4js configuration: '
+ "({ levels: { '#pants': 3 },\n appenders: { stdout: { type: 'stdout' } },\n"
+ " categories: { default: { appenders: [ 'stdout' ], level: 'trace' } } }) - "
+ 'level name "#pants" is not a valid identifier (must start with a letter, only contain A-Z,a-z,0-9,_)'
));
t.throws(() => {
log4js.configure({
@ -196,10 +208,12 @@ test('../../lib/logger', (batch) => {
appenders: { stdout: { type: 'stdout' } },
categories: { default: { appenders: ['stdout'], level: 'trace' } }
});
}, new Error('Problem with log4js configuration: ' +
"({ levels: { 'thing#pants': 3 },\n appenders: { stdout: { type: 'stdout' } },\n" +
" categories: { default: { appenders: [ 'stdout' ], level: 'trace' } } }) - " +
'level name "thing#pants" is not a valid identifier (must start with a letter, only contain A-Z,a-z,0-9,_)'));
}, new Error(
'Problem with log4js configuration: '
+ "({ levels: { 'thing#pants': 3 },\n appenders: { stdout: { type: 'stdout' } },\n"
+ " categories: { default: { appenders: [ 'stdout' ], level: 'trace' } } }) - "
+ 'level name "thing#pants" is not a valid identifier (must start with a letter, only contain A-Z,a-z,0-9,_)'
));
t.throws(() => {
log4js.configure({
@ -209,10 +223,12 @@ test('../../lib/logger', (batch) => {
appenders: { stdout: { type: 'stdout' } },
categories: { default: { appenders: ['stdout'], level: 'trace' } }
});
}, new Error('Problem with log4js configuration: ' +
"({ levels: { '1pants': 3 },\n appenders: { stdout: { type: 'stdout' } },\n" +
" categories: { default: { appenders: [ 'stdout' ], level: 'trace' } } }) - " +
'level name "1pants" is not a valid identifier (must start with a letter, only contain A-Z,a-z,0-9,_)'));
}, new Error(
'Problem with log4js configuration: '
+ "({ levels: { '1pants': 3 },\n appenders: { stdout: { type: 'stdout' } },\n"
+ " categories: { default: { appenders: [ 'stdout' ], level: 'trace' } } }) - "
+ 'level name "1pants" is not a valid identifier (must start with a letter, only contain A-Z,a-z,0-9,_)'
));
t.throws(() => {
log4js.configure({
@ -222,10 +238,12 @@ test('../../lib/logger', (batch) => {
appenders: { stdout: { type: 'stdout' } },
categories: { default: { appenders: ['stdout'], level: 'trace' } }
});
}, new Error('Problem with log4js configuration: ' +
"({ levels: { '2': 3 },\n appenders: { stdout: { type: 'stdout' } },\n" +
" categories: { default: { appenders: [ 'stdout' ], level: 'trace' } } }) - " +
'level name "2" is not a valid identifier (must start with a letter, only contain A-Z,a-z,0-9,_)'));
}, new Error(
'Problem with log4js configuration: '
+ "({ levels: { '2': 3 },\n appenders: { stdout: { type: 'stdout' } },\n"
+ " categories: { default: { appenders: [ 'stdout' ], level: 'trace' } } }) - "
+ 'level name "2" is not a valid identifier (must start with a letter, only contain A-Z,a-z,0-9,_)'
));
t.throws(() => {
log4js.configure({
@ -235,10 +253,12 @@ test('../../lib/logger', (batch) => {
appenders: { stdout: { type: 'stdout' } },
categories: { default: { appenders: ['stdout'], level: 'trace' } }
});
}, new Error('Problem with log4js configuration: ' +
"({ levels: { 'cheese!': 3 },\n appenders: { stdout: { type: 'stdout' } },\n" +
" categories: { default: { appenders: [ 'stdout' ], level: 'trace' } } }) - " +
'level name "cheese!" is not a valid identifier (must start with a letter, only contain A-Z,a-z,0-9,_)'));
}, new Error(
'Problem with log4js configuration: '
+ "({ levels: { 'cheese!': 3 },\n appenders: { stdout: { type: 'stdout' } },\n"
+ " categories: { default: { appenders: [ 'stdout' ], level: 'trace' } } }) - "
+ 'level name "cheese!" is not a valid identifier (must start with a letter, only contain A-Z,a-z,0-9,_)'
));
t.end();
});

View File

@ -1,8 +1,8 @@
'use strict';
const test = require('tap').test;
const layouts = require('../../lib/layouts');
const sandbox = require('@log4js-node/sandboxed-module');
const layouts = require('../../lib/layouts');
test('stderr appender', (t) => {
const output = [];

View File

@ -1,8 +1,8 @@
'use strict';
const test = require('tap').test;
const layouts = require('../../lib/layouts');
const sandbox = require('@log4js-node/sandboxed-module');
const layouts = require('../../lib/layouts');
test('stdout appender', (t) => {
const output = [];