mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 16:06:16 -04:00
fix: The log level is now respected again. (#6076)
This commit is contained in:
parent
d12119d3be
commit
51def0eba6
1 changed files with 21 additions and 22 deletions
|
@ -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
|
// 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. :(
|
// 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: {
|
categories: {
|
||||||
default: {appenders: ['console'], level: 'info'},
|
default: {appenders: ['console'], level},
|
||||||
}});
|
}});
|
||||||
const defaultLogLevel = 'INFO';
|
const defaultLogLevel = 'INFO';
|
||||||
|
|
||||||
const initLogging = (logLevel, config) => {
|
const initLogging = (logLevel, config) => {
|
||||||
// log4js.configure() modifies exports.logconfig so check for equality first.
|
// log4js.configure() modifies exports.logconfig so check for equality first.
|
||||||
const logConfigIsDefault = deepEqual(config, defaultLogConfig());
|
|
||||||
log4js.configure(config);
|
log4js.configure(config);
|
||||||
log4js.getLogger('console');
|
log4js.getLogger('console');
|
||||||
|
|
||||||
|
@ -67,19 +66,16 @@ const initLogging = (logLevel, config) => {
|
||||||
console.log = logger.info.bind(logger);
|
console.log = logger.info.bind(logger);
|
||||||
console.warn = logger.warn.bind(logger);
|
console.warn = logger.warn.bind(logger);
|
||||||
console.error = logger.error.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
|
// 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.
|
// 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 */
|
/* Root path of the installation */
|
||||||
exports.root = absolutePaths.findEtherpadRoot();
|
exports.root = absolutePaths.findEtherpadRoot();
|
||||||
logger.info('All relative paths will be interpreted relative to the identified ' +
|
logger.info('All relative paths will be interpreted relative to the identified ' +
|
||||||
`Etherpad base dir: ${exports.root}`);
|
`Etherpad base dir: ${exports.root}`);
|
||||||
exports.settingsFilename = absolutePaths.makeAbsolute(argv.settings || 'settings.json');
|
exports.settingsFilename = absolutePaths.makeAbsolute(argv.settings || 'settings.json');
|
||||||
exports.credentialsFilename = absolutePaths.makeAbsolute(argv.credentials || 'credentials.json');
|
exports.credentialsFilename = absolutePaths.makeAbsolute(argv.credentials || 'credentials.json');
|
||||||
|
|
||||||
|
@ -160,7 +156,7 @@ exports.defaultPadText = [
|
||||||
'Welcome to Etherpad!',
|
'Welcome to Etherpad!',
|
||||||
'',
|
'',
|
||||||
'This pad text is synchronized as you type, so that everyone viewing this page sees the same ' +
|
'This pad text is synchronized as you type, so that everyone viewing this page sees the same ' +
|
||||||
'text. This allows you to collaborate seamlessly on documents!',
|
'text. This allows you to collaborate seamlessly on documents!',
|
||||||
'',
|
'',
|
||||||
'Etherpad on Github: https://github.com/ether/etherpad-lite',
|
'Etherpad on Github: https://github.com/ether/etherpad-lite',
|
||||||
].join('\n');
|
].join('\n');
|
||||||
|
@ -298,7 +294,7 @@ exports.indentationOnNewLine = true;
|
||||||
/*
|
/*
|
||||||
* log4js appender configuration
|
* log4js appender configuration
|
||||||
*/
|
*/
|
||||||
exports.logconfig = defaultLogConfig();
|
exports.logconfig = null;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Deprecated cookie signing key.
|
* Deprecated cookie signing key.
|
||||||
|
@ -646,9 +642,9 @@ const lookupEnvironmentVariables = (obj) => {
|
||||||
|
|
||||||
if ((envVarValue === undefined) && (defaultValue === undefined)) {
|
if ((envVarValue === undefined) && (defaultValue === undefined)) {
|
||||||
logger.warn(`Environment variable "${envVarName}" does not contain any value for ` +
|
logger.warn(`Environment variable "${envVarName}" does not contain any value for ` +
|
||||||
`configuration key "${key}", and no default was given. Using null. ` +
|
`configuration key "${key}", and no default was given. Using null. ` +
|
||||||
'THIS BEHAVIOR MAY CHANGE IN A FUTURE VERSION OF ETHERPAD; you should ' +
|
'THIS BEHAVIOR MAY CHANGE IN A FUTURE VERSION OF ETHERPAD; you should ' +
|
||||||
'explicitly use "null" as the default if you want to continue to use null.');
|
'explicitly use "null" as the default if you want to continue to use null.');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We have to return null, because if we just returned undefined, the
|
* We have to return null, because if we just returned undefined, the
|
||||||
|
@ -659,7 +655,7 @@ const lookupEnvironmentVariables = (obj) => {
|
||||||
|
|
||||||
if ((envVarValue === undefined) && (defaultValue !== undefined)) {
|
if ((envVarValue === undefined) && (defaultValue !== undefined)) {
|
||||||
logger.debug(`Environment variable "${envVarName}" not found for ` +
|
logger.debug(`Environment variable "${envVarName}" not found for ` +
|
||||||
`configuration key "${key}". Falling back to default value.`);
|
`configuration key "${key}". Falling back to default value.`);
|
||||||
|
|
||||||
return coerceValue(defaultValue);
|
return coerceValue(defaultValue);
|
||||||
}
|
}
|
||||||
|
@ -726,7 +722,7 @@ const parseSettings = (settingsFilename, isSettings) => {
|
||||||
return replacedSettings;
|
return replacedSettings;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error(`There was an error processing your ${settingsType} ` +
|
logger.error(`There was an error processing your ${settingsType} ` +
|
||||||
`file from ${settingsFilename}: ${e.message}`);
|
`file from ${settingsFilename}: ${e.message}`);
|
||||||
|
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
@ -738,11 +734,13 @@ exports.reloadSettings = () => {
|
||||||
storeSettings(settings);
|
storeSettings(settings);
|
||||||
storeSettings(credentials);
|
storeSettings(credentials);
|
||||||
|
|
||||||
|
// Init logging config
|
||||||
|
exports.logconfig = defaultLogConfig(exports.loglevel ? exports.loglevel : defaultLogLevel);
|
||||||
initLogging(exports.loglevel, exports.logconfig);
|
initLogging(exports.loglevel, exports.logconfig);
|
||||||
|
|
||||||
if (!exports.skinName) {
|
if (!exports.skinName) {
|
||||||
logger.warn('No "skinName" parameter found. Please check out settings.json.template and ' +
|
logger.warn('No "skinName" parameter found. Please check out settings.json.template and ' +
|
||||||
'update your settings.json. Falling back to the default "colibris".');
|
'update your settings.json. Falling back to the default "colibris".');
|
||||||
exports.skinName = 'colibris';
|
exports.skinName = 'colibris';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -753,7 +751,7 @@ exports.reloadSettings = () => {
|
||||||
|
|
||||||
if (countPieces !== 1) {
|
if (countPieces !== 1) {
|
||||||
logger.error(`skinName must be the name of a directory under "${skinBasePath}". This is ` +
|
logger.error(`skinName must be the name of a directory under "${skinBasePath}". This is ` +
|
||||||
`not valid: "${exports.skinName}". Falling back to the default "colibris".`);
|
`not valid: "${exports.skinName}". Falling back to the default "colibris".`);
|
||||||
|
|
||||||
exports.skinName = 'colibris';
|
exports.skinName = 'colibris';
|
||||||
}
|
}
|
||||||
|
@ -764,7 +762,7 @@ exports.reloadSettings = () => {
|
||||||
// what if someone sets skinName == ".." or "."? We catch him!
|
// what if someone sets skinName == ".." or "."? We catch him!
|
||||||
if (absolutePaths.isSubdir(skinBasePath, skinPath) === false) {
|
if (absolutePaths.isSubdir(skinBasePath, skinPath) === false) {
|
||||||
logger.error(`Skin path ${skinPath} must be a subdirectory of ${skinBasePath}. ` +
|
logger.error(`Skin path ${skinPath} must be a subdirectory of ${skinBasePath}. ` +
|
||||||
'Falling back to the default "colibris".');
|
'Falling back to the default "colibris".');
|
||||||
|
|
||||||
exports.skinName = 'colibris';
|
exports.skinName = 'colibris';
|
||||||
skinPath = path.join(skinBasePath, exports.skinName);
|
skinPath = path.join(skinBasePath, exports.skinName);
|
||||||
|
@ -825,9 +823,9 @@ exports.reloadSettings = () => {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.warn('Declaring the sessionKey in the settings.json is deprecated. ' +
|
logger.warn('Declaring the sessionKey in the settings.json is deprecated. ' +
|
||||||
'This value is auto-generated now. Please remove the setting from the file. -- ' +
|
'This value is auto-generated now. Please remove the setting from the file. -- ' +
|
||||||
'If you are seeing this error after restarting using the Admin User ' +
|
'If you are seeing this error after restarting using the Admin User ' +
|
||||||
'Interface then you can ignore this message.');
|
'Interface then you can ignore this message.');
|
||||||
}
|
}
|
||||||
if (exports.sessionKey) {
|
if (exports.sessionKey) {
|
||||||
logger.warn(`The sessionKey setting and ${sessionkeyFilename} file are deprecated; ` +
|
logger.warn(`The sessionKey setting and ${sessionkeyFilename} file are deprecated; ` +
|
||||||
|
@ -847,7 +845,7 @@ exports.reloadSettings = () => {
|
||||||
if (exports.ip === '') {
|
if (exports.ip === '') {
|
||||||
// using Unix socket for connectivity
|
// using Unix socket for connectivity
|
||||||
logger.warn('The settings file contains an empty string ("") for the "ip" parameter. The ' +
|
logger.warn('The settings file contains an empty string ("") for the "ip" parameter. The ' +
|
||||||
'"port" parameter will be interpreted as the path to a Unix socket to bind at.');
|
'"port" parameter will be interpreted as the path to a Unix socket to bind at.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -871,3 +869,4 @@ exports.exportedForTestingOnly = {
|
||||||
|
|
||||||
// initially load settings
|
// initially load settings
|
||||||
exports.reloadSettings();
|
exports.reloadSettings();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue