mirror of
https://github.com/log4js-node/log4js-node.git
synced 2025-12-08 19:26:01 +00:00
Merge pull request #870 from log4js-node/fixes-for-node-v12
Fixes for node v12
This commit is contained in:
commit
8f0054473d
@ -2,6 +2,7 @@ language: node_js
|
||||
dist: trusty
|
||||
sudo: false
|
||||
node_js:
|
||||
- "12"
|
||||
- "10"
|
||||
- "8"
|
||||
- "6"
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
# log4js-node changelog
|
||||
|
||||
## 4.1.1
|
||||
* [Fix layout problem in node v12](https://github.com/log4js-node/log4js-node/pull/860) - thanks [@bjornstar](https://github.com/bjornstar)
|
||||
* [Add missing types for addLevels](https://github.com/log4js-node/log4js-node/pull/867) - thanks [@Ivkaa](https://github.com/Ivkaa)
|
||||
* [Allow any return type for layout function](https://github.com/log4js-node/log4js-node/pull/845) - thanks [@xinbenlv](https://github.com/xinbenlv)
|
||||
|
||||
|
||||
2464
package-lock.json
generated
2464
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
16
package.json
16
package.json
@ -47,18 +47,18 @@
|
||||
"streamroller": "^1.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@log4js-node/sandboxed-module": "^2.2.0",
|
||||
"codecov": "^3.0.2",
|
||||
"conventional-changelog": "^3.0.6",
|
||||
"@log4js-node/sandboxed-module": "^2.2.1",
|
||||
"codecov": "^3.3.0",
|
||||
"conventional-changelog": "^3.1.4",
|
||||
"deep-freeze": "0.0.1",
|
||||
"eslint": "^5.14.1",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint-config-airbnb-base": "^13.1.0",
|
||||
"eslint-import-resolver-node": "^0.3.1",
|
||||
"eslint-plugin-import": "^2.11.0",
|
||||
"eslint-plugin-import": "^2.17.2",
|
||||
"husky": "^1.3.1",
|
||||
"nyc": "^13.3.0",
|
||||
"tap": "^12.6.1",
|
||||
"typescript": "^3.3.3",
|
||||
"nyc": "^14.1.0",
|
||||
"tap": "^12.6.5",
|
||||
"typescript": "^3.4.5",
|
||||
"validate-commit-msg": "^2.14.0"
|
||||
},
|
||||
"browser": {
|
||||
|
||||
@ -38,191 +38,131 @@ 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.'
|
||||
t.throws(
|
||||
() => log4js.configure({}),
|
||||
'- 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.'
|
||||
t.throws(
|
||||
() => log4js.configure({ 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.'
|
||||
t.throws(
|
||||
() => log4js.configure({ 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.'
|
||||
);
|
||||
t.throws(
|
||||
() => log4js.configure({ appenders: [], categories: [] }),
|
||||
error
|
||||
'- must have a property "appenders" of type object.'
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
|
||||
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")'
|
||||
);
|
||||
t.throws(
|
||||
() => log4js.configure({ appenders: { thing: 'cheese' }, categories: {} }),
|
||||
error
|
||||
'- appender "thing" is not valid (must be an object with property "type")'
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
|
||||
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.'
|
||||
);
|
||||
t.throws(
|
||||
() => log4js.configure({ appenders: {}, categories: {} }),
|
||||
error
|
||||
'- must define at least one appender.'
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
|
||||
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")'
|
||||
);
|
||||
t.throws(
|
||||
() => log4js.configure({ appenders: { stdout: { type: 'stdout' } }, categories: { thing: 'cheese' } }),
|
||||
error
|
||||
'- category "thing" is not valid (must be an object with properties "appenders" and "level")'
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
|
||||
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.'
|
||||
);
|
||||
t.throws(
|
||||
() => log4js.configure({
|
||||
appenders: { stdout: { type: 'stdout' } },
|
||||
categories: { thing: { appenders: ['stdout'], level: 'ERROR' } }
|
||||
}),
|
||||
error
|
||||
'- must define a "default" category.'
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
|
||||
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.'
|
||||
);
|
||||
t.throws(
|
||||
() => log4js.configure({ appenders: { stdout: { type: 'stdout' } }, categories: {} }),
|
||||
error
|
||||
'- must define at least one category.'
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
|
||||
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)'
|
||||
);
|
||||
t.throws(
|
||||
() => log4js.configure({
|
||||
appenders: { stdout: { type: 'stdout' } },
|
||||
categories: { thing: { appenders: {}, level: 'ERROR' } }
|
||||
}),
|
||||
error
|
||||
'- category "thing" is not valid (appenders must be an array of appender names)'
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
|
||||
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)'
|
||||
);
|
||||
t.throws(
|
||||
() => log4js.configure({
|
||||
appenders: { stdout: { type: 'stdout' } },
|
||||
categories: { thing: { appenders: [], level: 'ERROR' } }
|
||||
}),
|
||||
error
|
||||
'- category "thing" is not valid (appenders must contain at least one appender name)'
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
|
||||
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)'
|
||||
);
|
||||
t.throws(
|
||||
() => log4js.configure({
|
||||
appenders: { stdout: { type: 'stdout' } },
|
||||
categories: { thing: { appenders: ['cheese'], level: 'ERROR' } }
|
||||
}),
|
||||
error
|
||||
'- category "thing" is not valid (appender "cheese" is not defined)'
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
|
||||
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)'
|
||||
);
|
||||
t.throws(
|
||||
() => log4js.configure({
|
||||
appenders: { stdout: { type: 'stdout' } },
|
||||
categories: { default: { appenders: ['stdout'], level: 'Biscuits' } }
|
||||
}),
|
||||
error
|
||||
'- category "default" is not valid (level "Biscuits" not recognised; valid levels are ALL, TRACE'
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
|
||||
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)'
|
||||
);
|
||||
t.throws(
|
||||
() => log4js.configure({
|
||||
appenders: { thing: { type: 'cheese' } },
|
||||
categories: { default: { appenders: ['thing'], level: 'ERROR' } }
|
||||
}),
|
||||
error
|
||||
'- appender "thing" is not valid (type "cheese" could not be found)'
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
|
||||
@ -118,12 +118,8 @@ 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'
|
||||
));
|
||||
},
|
||||
'level "cheese".value must have an integer value');
|
||||
|
||||
t.throws(() => {
|
||||
log4js.configure({
|
||||
@ -133,12 +129,8 @@ 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'
|
||||
));
|
||||
},
|
||||
'level "cheese" must be an object');
|
||||
|
||||
t.throws(() => {
|
||||
log4js.configure({
|
||||
@ -148,12 +140,8 @@ 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'
|
||||
));
|
||||
},
|
||||
"level \"cheese\" must have a 'value' property");
|
||||
|
||||
t.throws(() => {
|
||||
log4js.configure({
|
||||
@ -163,12 +151,8 @@ 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'
|
||||
));
|
||||
},
|
||||
"level \"cheese\" must have a 'colour' property");
|
||||
|
||||
t.throws(() => {
|
||||
log4js.configure({
|
||||
@ -178,12 +162,8 @@ 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'
|
||||
));
|
||||
},
|
||||
'level "cheese".colour must be one of white, grey, black, blue, cyan, green, magenta, red, yellow');
|
||||
|
||||
t.throws(() => {
|
||||
log4js.configure({
|
||||
@ -193,12 +173,8 @@ 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,_)'
|
||||
));
|
||||
},
|
||||
'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({
|
||||
@ -208,12 +184,8 @@ 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,_)'
|
||||
));
|
||||
},
|
||||
'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({
|
||||
@ -223,12 +195,8 @@ 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,_)'
|
||||
));
|
||||
},
|
||||
'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({
|
||||
@ -238,12 +206,8 @@ 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,_)'
|
||||
));
|
||||
},
|
||||
'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({
|
||||
@ -253,12 +217,8 @@ 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,_)'
|
||||
));
|
||||
},
|
||||
'level name "cheese!" is not a valid identifier (must start with a letter, only contain A-Z,a-z,0-9,_)');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user