fix: The log level is now respected again. (#6076)

This commit is contained in:
SamTV12345 2023-12-17 22:13:13 +01:00 committed by GitHub
parent d12119d3be
commit 51def0eba6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -50,15 +50,14 @@ const nonSettings = [
// This is a function to make it easy to create a new instance. It is important to not reuse a
// config object after passing it to log4js.configure() because that method mutates the object. :(
const defaultLogConfig = () => ({appenders: {console: {type: 'console'}},
const defaultLogConfig = (level) => ({appenders: {console: {type: 'console'}},
categories: {
default: {appenders: ['console'], level: 'info'},
default: {appenders: ['console'], level},
}});
const defaultLogLevel = 'INFO';
const initLogging = (logLevel, config) => {
// log4js.configure() modifies exports.logconfig so check for equality first.
const logConfigIsDefault = deepEqual(config, defaultLogConfig());
log4js.configure(config);
log4js.getLogger('console');
@ -67,14 +66,11 @@ const initLogging = (logLevel, config) => {
console.log = logger.info.bind(logger);
console.warn = logger.warn.bind(logger);
console.error = logger.error.bind(logger);
// Log the warning after configuring log4js to increase the chances the user will see it.
if (!logConfigIsDefault) logger.warn('The logconfig setting is deprecated.');
};
// Initialize logging as early as possible with reasonable defaults. Logging will be re-initialized
// with the user's chosen log level and logger config after the settings have been loaded.
initLogging(defaultLogLevel, defaultLogConfig());
initLogging(defaultLogLevel, defaultLogConfig(defaultLogLevel));
/* Root path of the installation */
exports.root = absolutePaths.findEtherpadRoot();
@ -298,7 +294,7 @@ exports.indentationOnNewLine = true;
/*
* log4js appender configuration
*/
exports.logconfig = defaultLogConfig();
exports.logconfig = null;
/*
* Deprecated cookie signing key.
@ -738,6 +734,8 @@ exports.reloadSettings = () => {
storeSettings(settings);
storeSettings(credentials);
// Init logging config
exports.logconfig = defaultLogConfig(exports.loglevel ? exports.loglevel : defaultLogLevel);
initLogging(exports.loglevel, exports.logconfig);
if (!exports.skinName) {
@ -871,3 +869,4 @@ exports.exportedForTestingOnly = {
// initially load settings
exports.reloadSettings();