mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +01:00
tests: Disable non-test logging unless level <= DEBUG
This makes it easier to see the test results, and it hides some scary-looking but intentional error messages. This code will likely have to be updated if/when we change the logging library (see issue #1922).
This commit is contained in:
parent
34b232d658
commit
c74b254334
1 changed files with 10 additions and 0 deletions
|
@ -14,10 +14,19 @@ exports.baseUrl = null;
|
||||||
exports.httpServer = null;
|
exports.httpServer = null;
|
||||||
exports.logger = log4js.getLogger('test');
|
exports.logger = log4js.getLogger('test');
|
||||||
|
|
||||||
|
const logLevel = exports.logger.level;
|
||||||
|
|
||||||
exports.init = async function() {
|
exports.init = async function() {
|
||||||
if (inited) return exports.agent;
|
if (inited) return exports.agent;
|
||||||
inited = true;
|
inited = true;
|
||||||
|
|
||||||
|
if (!logLevel.isLessThanOrEqualTo(log4js.levels.DEBUG)) {
|
||||||
|
exports.logger.warn('Disabling non-test logging for the duration of the test. ' +
|
||||||
|
'To enable non-test logging, change the loglevel setting to DEBUG.');
|
||||||
|
log4js.setGlobalLogLevel(log4js.levels.OFF);
|
||||||
|
exports.logger.setLevel(logLevel);
|
||||||
|
}
|
||||||
|
|
||||||
// Note: This is only a shallow backup.
|
// Note: This is only a shallow backup.
|
||||||
backups.settings = Object.assign({}, settings);
|
backups.settings = Object.assign({}, settings);
|
||||||
// Start the Etherpad server on a random unused port.
|
// Start the Etherpad server on a random unused port.
|
||||||
|
@ -37,6 +46,7 @@ exports.init = async function() {
|
||||||
await server.stop();
|
await server.stop();
|
||||||
// Note: This does not unset settings that were added.
|
// Note: This does not unset settings that were added.
|
||||||
Object.assign(settings, backups.settings);
|
Object.assign(settings, backups.settings);
|
||||||
|
log4js.setGlobalLogLevel(logLevel);
|
||||||
});
|
});
|
||||||
|
|
||||||
return exports.agent;
|
return exports.agent;
|
||||||
|
|
Loading…
Reference in a new issue