Merge pull request #1164 from log4js-node/emit-deprecation

emit deprecation
This commit is contained in:
Lam Wei Li 2022-01-23 21:32:16 +08:00 committed by GitHub
commit 49c91738ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -68,9 +68,17 @@ const createAppender = (name, config) => {
`appender "${name}" is not valid (type "${appenderConfig.type}" could not be found)`
);
if (appenderModule.appender) {
process.emitWarning(
`Appender ${appenderConfig.type} exports an appender function.`,
"DeprecationWarning", "log4js-node-DEP0001"
);
debug(`DEPRECATION: Appender ${appenderConfig.type} exports an appender function.`);
}
if (appenderModule.shutdown) {
process.emitWarning(
`Appender ${appenderConfig.type} exports a shutdown function.`,
"DeprecationWarning", "log4js-node-DEP0002"
);
debug(`DEPRECATION: Appender ${appenderConfig.type} exports a shutdown function.`);
}

View File

@ -155,6 +155,11 @@ function patternLayout(pattern, tokens) {
format = dateFormat.ISO8601_WITH_TZ_OFFSET_FORMAT;
break;
case 'ABSOLUTE':
process.emitWarning(
"Pattern %d{ABSOLUTE} is deprecated in favor of %d{ABSOLUTETIME}. " +
"Please use %d{ABSOLUTETIME} instead.",
"DeprecationWarning", "log4js-node-DEP0003"
);
debug("DEPRECATION: Pattern %d{ABSOLUTE} is deprecated and replaced by %d{ABSOLUTETIME}.");
// falls through
case 'ABSOLUTETIME':
@ -162,6 +167,11 @@ function patternLayout(pattern, tokens) {
format = dateFormat.ABSOLUTETIME_FORMAT;
break;
case 'DATE':
process.emitWarning(
"Pattern %d{DATE} is deprecated due to the confusion it causes when used. " +
"Please use %d{DATETIME} instead.",
"DeprecationWarning", "log4js-node-DEP0004"
);
debug("DEPRECATION: Pattern %d{DATE} is deprecated and replaced by %d{DATETIME}.");
// falls through
case 'DATETIME':