From 4d054505a8ef2f9cf5c61186a6dc29484e6f7baf Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 15 Jun 2018 07:52:13 +1000 Subject: [PATCH] chore: removed slack appender --- docs/slack.md | 31 --- lib/appenders/slack.js | 47 ---- package-lock.json | 473 --------------------------------- package.json | 1 - test/tap/slackAppender-test.js | 163 ------------ types/log4js.d.ts | 15 -- 6 files changed, 730 deletions(-) delete mode 100644 docs/slack.md delete mode 100644 lib/appenders/slack.js delete mode 100644 test/tap/slackAppender-test.js diff --git a/docs/slack.md b/docs/slack.md deleted file mode 100644 index f1cfbf4..0000000 --- a/docs/slack.md +++ /dev/null @@ -1,31 +0,0 @@ -# Slack Appender - -Sends log events to a [slack](https://slack.com) channel. To use this appender you will need to include [slack-node](https://www.npmjs.com/package/slack-node) in your application's dependencies. - -## Configuration - -* `type` - `slack` -* `token` - `string` - your Slack API token (see the slack and slack-node docs) -* `channel_id` - `string` - the channel to send log messages -* `icon_url` - `string` (optional) - the icon to use for the message -* `username` - `string` - the username to display with the message -* `layout` - `object` (optional, defaults to `basicLayout`) - the layout to use for the message (see [layouts](layouts.md)). - -## Example - -```javascript -log4js.configure({ - appenders: { - alerts: { - type: 'slack', - token: 'abc123def', - channel_id: 'prod-alerts', - username: 'our_application' - } - }, - categories: { - default: { appenders: ['alerts'], level: 'error' } - } -}); -``` -This configuration will send all error (and above) messages to the `prod-alerts` slack channel, with the username `our_application`. diff --git a/lib/appenders/slack.js b/lib/appenders/slack.js deleted file mode 100644 index e348b93..0000000 --- a/lib/appenders/slack.js +++ /dev/null @@ -1,47 +0,0 @@ -'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) { - const appender = (loggingEvent) => { - const data = { - channel_id: _config.channel_id, - text: layout(loggingEvent, _config.timezoneOffset), - icon_url: _config.icon_url, - username: _config.username - }; - - /* eslint no-unused-vars:0 */ - slack.api('chat.postMessage', { - channel: data.channel_id, - text: data.text, - icon_url: data.icon_url, - username: data.username - }, (err, response) => { - if (err) { - throw err; - } - }); - }; - - // trigger a deprecation warning. - appender.deprecated = '@logj4s-node/slack'; - return appender; -} - -function configure(_config, layouts) { - const slack = new Slack(_config.token); - - let layout = layouts.basicLayout; - if (_config.layout) { - layout = layouts.layout(_config.layout.type, _config.layout); - } - - return slackAppender(_config, layout, slack); -} - -module.exports.configure = configure; diff --git a/package-lock.json b/package-lock.json index a4b0a25..9da9e01 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5868,479 +5868,6 @@ "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "dev": true }, - "slack-node": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/slack-node/-/slack-node-0.2.0.tgz", - "integrity": "sha1-3kuN3aqLeT9h29KTgQT9q/N9+jA=", - "optional": true, - "requires": { - "requestretry": "^1.2.2" - }, - "dependencies": { - "requestretry": { - "version": "1.12.2", - "resolved": "https://registry.npmjs.org/requestretry/-/requestretry-1.12.2.tgz", - "integrity": "sha1-E844pM5OgJ88nsbUyjt7m6Ss8mw=", - "optional": true, - "requires": { - "extend": "^3.0.0", - "lodash": "^4.15.0", - "request": "^2.74.0", - "when": "^3.7.7" - }, - "dependencies": { - "extend": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", - "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=" - }, - "lodash": { - "version": "4.17.4", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", - "optional": true - }, - "request": { - "version": "2.83.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.83.0.tgz", - "integrity": "sha1-ygtl2gLtYpNYh4COb1EDgQNOM1Y=", - "optional": true, - "requires": { - "aws-sign2": "~0.7.0", - "aws4": "^1.6.0", - "caseless": "~0.12.0", - "combined-stream": "~1.0.5", - "extend": "~3.0.1", - "forever-agent": "~0.6.1", - "form-data": "~2.3.1", - "har-validator": "~5.0.3", - "hawk": "~6.0.2", - "http-signature": "~1.2.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.17", - "oauth-sign": "~0.8.2", - "performance-now": "^2.1.0", - "qs": "~6.5.1", - "safe-buffer": "^5.1.1", - "stringstream": "~0.0.5", - "tough-cookie": "~2.3.3", - "tunnel-agent": "^0.6.0", - "uuid": "^3.1.0" - }, - "dependencies": { - "aws-sign2": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", - "optional": true - }, - "aws4": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", - "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=", - "optional": true - }, - "caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", - "optional": true - }, - "combined-stream": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", - "requires": { - "delayed-stream": "~1.0.0" - }, - "dependencies": { - "delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" - } - } - }, - "forever-agent": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", - "optional": true - }, - "form-data": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.1.tgz", - "integrity": "sha1-b7lPvXGIUwbXPRXMSX/kzE7NRL8=", - "optional": true, - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.5", - "mime-types": "^2.1.12" - }, - "dependencies": { - "asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", - "optional": true - } - } - }, - "har-validator": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", - "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", - "optional": true, - "requires": { - "ajv": "^5.1.0", - "har-schema": "^2.0.0" - }, - "dependencies": { - "ajv": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.3.0.tgz", - "integrity": "sha1-RBT/dKUIecII7l/cgm4ywwNUnto=", - "optional": true, - "requires": { - "co": "^4.6.0", - "fast-deep-equal": "^1.0.0", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.3.0" - }, - "dependencies": { - "co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", - "optional": true - }, - "fast-deep-equal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz", - "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=", - "optional": true - }, - "fast-json-stable-stringify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", - "optional": true - }, - "json-schema-traverse": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=", - "optional": true - } - } - }, - "har-schema": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", - "optional": true - } - } - }, - "hawk": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", - "optional": true, - "requires": { - "boom": "4.x.x", - "cryptiles": "3.x.x", - "hoek": "4.x.x", - "sntp": "2.x.x" - }, - "dependencies": { - "boom": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz", - "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=", - "optional": true, - "requires": { - "hoek": "4.x.x" - } - }, - "cryptiles": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz", - "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=", - "optional": true, - "requires": { - "boom": "5.x.x" - }, - "dependencies": { - "boom": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", - "optional": true, - "requires": { - "hoek": "4.x.x" - } - } - } - }, - "hoek": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.0.tgz", - "integrity": "sha1-ctnQdU9/4lyi0BrY+PmpRJqJUm0=" - }, - "sntp": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", - "optional": true, - "requires": { - "hoek": "4.x.x" - } - } - } - }, - "http-signature": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", - "optional": true, - "requires": { - "assert-plus": "^1.0.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" - }, - "jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", - "optional": true, - "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.2.3", - "verror": "1.10.0" - }, - "dependencies": { - "extsprintf": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" - }, - "json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", - "optional": true - }, - "verror": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", - "optional": true, - "requires": { - "assert-plus": "^1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "^1.2.0" - }, - "dependencies": { - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "optional": true - } - } - } - } - }, - "sshpk": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz", - "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=", - "optional": true, - "requires": { - "asn1": "~0.2.3", - "assert-plus": "^1.0.0", - "bcrypt-pbkdf": "^1.0.0", - "dashdash": "^1.12.0", - "ecc-jsbn": "~0.1.1", - "getpass": "^0.1.1", - "jsbn": "~0.1.0", - "tweetnacl": "~0.14.0" - }, - "dependencies": { - "asn1": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", - "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=", - "optional": true - }, - "bcrypt-pbkdf": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", - "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", - "optional": true, - "requires": { - "tweetnacl": "^0.14.3" - } - }, - "dashdash": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", - "optional": true, - "requires": { - "assert-plus": "^1.0.0" - } - }, - "ecc-jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", - "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", - "optional": true, - "requires": { - "jsbn": "~0.1.0" - } - }, - "getpass": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", - "optional": true, - "requires": { - "assert-plus": "^1.0.0" - } - }, - "jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", - "optional": true - }, - "tweetnacl": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", - "optional": true - } - } - } - } - }, - "is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", - "optional": true - }, - "isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", - "optional": true - }, - "json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", - "optional": true - }, - "mime-types": { - "version": "2.1.17", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", - "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", - "requires": { - "mime-db": "~1.30.0" - }, - "dependencies": { - "mime-db": { - "version": "1.30.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", - "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=" - } - } - }, - "oauth-sign": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=", - "optional": true - }, - "performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", - "optional": true - }, - "qs": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", - "optional": true - }, - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=" - }, - "stringstream": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", - "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=", - "optional": true - }, - "tough-cookie": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz", - "integrity": "sha1-C2GKVWW23qkL80JdBNVe3EdadWE=", - "optional": true, - "requires": { - "punycode": "^1.4.1" - }, - "dependencies": { - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", - "optional": true - } - } - }, - "tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "optional": true, - "requires": { - "safe-buffer": "^5.0.1" - } - }, - "uuid": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", - "integrity": "sha1-PdPT55Crwk17DToDT/q6vijrvAQ=", - "optional": true - } - } - }, - "when": { - "version": "3.7.8", - "resolved": "https://registry.npmjs.org/when/-/when-3.7.8.tgz", - "integrity": "sha1-xxMLan6gRpPoQs3J56Hyqjmjn4I=", - "optional": true - } - } - } - } - }, "slice-ansi": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", diff --git a/package.json b/package.json index 7f7ddfa..64769db 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,6 @@ "validate-commit-msg": "^2.14.0" }, "optionalDependencies": { - "slack-node": "~0.2.0", "axios": "^0.15.3", "amqplib": "^0.5.2" }, diff --git a/test/tap/slackAppender-test.js b/test/tap/slackAppender-test.js deleted file mode 100644 index d2a643a..0000000 --- a/test/tap/slackAppender-test.js +++ /dev/null @@ -1,163 +0,0 @@ -'use strict'; - -const test = require('tap').test; -const sandbox = require('@log4js-node/sandboxed-module'); -const realLayouts = require('../../lib/layouts'); - -function setupLogging(category, options) { - const msgs = []; - - const slackCredentials = { - token: options.token, - channel_id: options.channel_id, - username: options.username, - format: options.format, - icon_url: options.icon_url - }; - const fakeSlack = (function (key) { - function constructor() { - return { - options: key, - api: function (action, data, callback) { - msgs.push(data); - callback(false, { status: 'sent' }); - } - }; - } - - return constructor(key); - }); - - const fakeLayouts = { - layout: function (type, config) { - this.type = type; - this.config = config; - return realLayouts.messagePassThroughLayout; - }, - basicLayout: realLayouts.basicLayout, - coloredLayout: realLayouts.coloredLayout, - messagePassThroughLayout: realLayouts.messagePassThroughLayout - }; - - const fakeConsole = { - errors: [], - logs: [], - error: function (msg, value) { - this.errors.push({ msg: msg, value: value }); - }, - log: function (msg, value) { - this.logs.push({ msg: msg, value: value }); - } - }; - - const log4js = sandbox.require('../../lib/log4js', { - requires: { - 'slack-node': fakeSlack, - './layouts': fakeLayouts - }, - globals: { - console: fakeConsole - } - }); - - options.type = 'slack'; - log4js.configure({ - appenders: { - slack: options - }, - categories: { - default: { appenders: ['slack'], level: 'trace' } - } - }); - - return { - logger: log4js.getLogger(category), - mailer: fakeSlack, - layouts: fakeLayouts, - console: fakeConsole, - messages: msgs, - credentials: slackCredentials - }; -} - -function checkMessages(assert, result) { - for (let i = 0; i < result.messages.length; ++i) { - assert.equal(result.messages[i].channel, '#CHANNEL'); - assert.equal(result.messages[i].username, 'USERNAME'); - assert.ok(new RegExp(`.+Log event #${i + 1}`).test(result.messages[i].text)); - } -} - -test('log4js slackAppender', (batch) => { - batch.test('slack setup', (t) => { - const result = setupLogging('slack setup', { - token: 'TOKEN', - channel_id: '#CHANNEL', - username: 'USERNAME', - format: 'FORMAT', - icon_url: 'ICON_URL' - }); - - t.test('slack credentials should match', (assert) => { - assert.equal(result.credentials.token, 'TOKEN'); - assert.equal(result.credentials.channel_id, '#CHANNEL'); - assert.equal(result.credentials.username, 'USERNAME'); - assert.equal(result.credentials.format, 'FORMAT'); - assert.equal(result.credentials.icon_url, 'ICON_URL'); - assert.end(); - }); - t.end(); - }); - - batch.test('basic usage', (t) => { - const setup = setupLogging('basic usage', { - token: 'TOKEN', - channel_id: '#CHANNEL', - username: 'USERNAME', - format: 'FORMAT', - icon_url: 'ICON_URL', - }); - - setup.logger.info('Log event #1'); - - t.equal(setup.messages.length, 1, 'should be one message only'); - checkMessages(t, setup); - t.end(); - }); - - batch.test('config with layout', (t) => { - const result = setupLogging('config with layout', { - layout: { - type: 'tester' - } - }); - t.equal(result.layouts.type, 'tester', 'should configure layout'); - t.end(); - }); - - batch.test('separate notification for each event', (t) => { - const setup = setupLogging('separate notification for each event', { - token: 'TOKEN', - channel_id: '#CHANNEL', - username: 'USERNAME', - format: 'FORMAT', - icon_url: 'ICON_URL', - }); - setTimeout(() => { - setup.logger.info('Log event #1'); - }, 0); - setTimeout(() => { - setup.logger.info('Log event #2'); - }, 500); - setTimeout(() => { - setup.logger.info('Log event #3'); - }, 1100); - setTimeout(() => { - t.equal(setup.messages.length, 3, 'should be three messages'); - checkMessages(t, setup); - t.end(); - }, 3000); - }); - - batch.end(); -}); diff --git a/types/log4js.d.ts b/types/log4js.d.ts index f55561f..1a582ff 100644 --- a/types/log4js.d.ts +++ b/types/log4js.d.ts @@ -220,20 +220,6 @@ export interface MultiprocessAppender { loggerHost?: string; } -export interface SlackAppender { - type: 'slack'; - // your Slack API token (see the slack and slack-node docs) - token: string; - // the channel to send log messages - channel_id: string; - // the icon to use for the message - icon_url?: string; - // the username to display with the message - username: string; - // (defaults to basicLayout) - the layout to use for the message. - layout?: Layout; -} - export interface RecordingAppender { type: 'recording'; } @@ -265,7 +251,6 @@ export type Appender = CategoryFilterAppender | LogLevelFilterAppender | MultiFileAppender | MultiprocessAppender - | SlackAppender | RecordingAppender | StandardErrorAppender | StandardOutputAppender