Adding a layoutType (#6559)

This will allow end users to change the console output to not output colors
This commit is contained in:
Helder Sepulveda 2024-08-05 15:28:48 -04:00 committed by GitHub
parent 5c71151b80
commit c8797efaf2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 4 deletions

View file

@ -648,6 +648,13 @@
*/
"loglevel": "INFO",
/*
* The log layout type to use.
*
* Valid values: basic, colored
*/
"logLayoutType": "colored",
/* Override any strings found in locale directories */
"customLocaleStrings": {},

View file

@ -54,13 +54,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 = (level: string) => ({
appenders: {console: {type: 'console'}},
const defaultLogConfig = (level: string, layoutType: string) => ({
appenders: {console: {type: 'console', layout: {type: layoutType}}},
categories: {
default: {appenders: ['console'], level},
}
});
const defaultLogLevel = 'INFO';
const defaultLogLayoutType = 'colored';
const initLogging = (config: any) => {
// log4js.configure() modifies exports.logconfig so check for equality first.
@ -76,7 +77,7 @@ const initLogging = (config: any) => {
// 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(defaultLogConfig(defaultLogLevel));
initLogging(defaultLogConfig(defaultLogLevel, defaultLogLayoutType));
/* Root path of the installation */
exports.root = absolutePaths.findEtherpadRoot();
@ -291,6 +292,11 @@ exports.allowUnknownFileEnds = true;
*/
exports.loglevel = defaultLogLevel;
/**
* The log layout type of log4js
*/
exports.logLayoutType = defaultLogLayoutType;
/**
* Disable IP logging
*/
@ -817,7 +823,12 @@ exports.reloadSettings = () => {
storeSettings(credentials);
// Init logging config
exports.logconfig = defaultLogConfig(exports.loglevel ? exports.loglevel : defaultLogLevel);
exports.logconfig = defaultLogConfig(
exports.loglevel ? exports.loglevel : defaultLogLevel,
exports.logLayoutType ? exports.logLayoutType : defaultLogLayoutType
);
logger.warn("loglevel: " + exports.loglevel);
logger.warn("logLayoutType: " + exports.logLayoutType);
initLogging(exports.logconfig);
if (!exports.skinName) {