Fixed all log levels.

This commit is contained in:
SamTV12345 2023-10-22 18:24:04 +02:00
parent 0c3e3a8613
commit 188d58607c

View file

@ -52,7 +52,7 @@ const nonSettings = [
// 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 = () => ({appenders: {console: {type: 'console'}},
categories: { categories: {
default: { appenders: ['console'], level: 'info'} default: {appenders: ['console'], level: 'info'},
}}); }});
const defaultLogLevel = 'INFO'; const defaultLogLevel = 'INFO';
@ -60,8 +60,14 @@ 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()); const logConfigIsDefault = deepEqual(config, defaultLogConfig());
log4js.configure(config); log4js.configure(config);
log4js.getLogger("console"); log4js.getLogger('console');
console.log = logger.info.bind(logger)
// Overwrites for console output methods
console.debug = logger.debug.bind(logger);
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. // Log the warning after configuring log4js to increase the chances the user will see it.
if (!logConfigIsDefault) logger.warn('The logconfig setting is deprecated.'); if (!logConfigIsDefault) logger.warn('The logconfig setting is deprecated.');
}; };