fix: deprecate the slack appender

This commit is contained in:
Gareth Jones 2018-06-14 08:33:45 +10:00
parent 8754870a91
commit b13d045baa
3 changed files with 11 additions and 3 deletions

View File

@ -31,7 +31,6 @@ The following appenders are included with log4js. Some require extra dependencie
* [multiFile](multiFile.md)
* [multiprocess](multiprocess.md)
* [recording](recording.md)
* [slack](slack.md)
* [stderr](stderr.md)
* [stdout](stdout.md)
* [rabbitmq](rabbitmq.md)
@ -46,6 +45,7 @@ The following appenders are supported by log4js, but will issue deprecation warn
* [logstashUDP](https://github.com/log4js-node/logstashUDP)
* [mailgun](https://github.com/log4js-node/mailgun)
* [redis](https://github.com/log4js-node/redis)
* [slack](https://github.com/log4js-node/slack)
* [smtp](https://github.com/log4js-node/smtp)
For example, if you were previously using the gelf appender (`type: 'gelf'`) then you should add `@log4js-node/gelf` to your dependencies and change the type to `type: '@log4js-node/gelf'`.

View File

@ -4,7 +4,7 @@ const log4js = require('../lib/log4js');
log4js.configure({
appenders: {
slack: {
type: 'slack',
type: '@log4js-node/slack',
token: 'TOKEN',
channel_id: '#CHANNEL',
username: 'USERNAME',

View File

@ -1,9 +1,13 @@
'use strict';
/**
* This appender has been deprecated.
* Updates and bug fixes should be made against https://github.com/log4js-node/slack
*/
const Slack = require('slack-node');
function slackAppender(_config, layout, slack) {
return (loggingEvent) => {
const appender = (loggingEvent) => {
const data = {
channel_id: _config.channel_id,
text: layout(loggingEvent, _config.timezoneOffset),
@ -23,6 +27,10 @@ function slackAppender(_config, layout, slack) {
}
});
};
// trigger a deprecation warning.
appender.deprecated = '@logj4s-node/slack';
return appender;
}
function configure(_config, layouts) {