Skip to content

Commit

Permalink
Merge pull request #1164 from log4js-node/emit-deprecation
Browse files Browse the repository at this point in the history
emit deprecation
  • Loading branch information
lamweili committed Jan 23, 2022
2 parents 4deffd1 + 3226b3d commit 49c9173
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/appenders/index.js
Expand Up @@ -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.`);
}

Expand Down
10 changes: 10 additions & 0 deletions lib/layouts.js
Expand Up @@ -155,13 +155,23 @@ 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':
case 'ABSOLUTETIME_FORMAT':
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':
Expand Down

0 comments on commit 49c9173

Please sign in to comment.