Slack Logging Plugin
A plugin for logger-nodejs that allows you to send logs to slack
Usage:
const Logger = ;const SlackPlugin = ; const slackPlugin = webhook: 'https://hooks.slack.com/services/your/webhook' channel: '#api-errors' username: 'API' logLevel: 'error'; const log = plugins: slackPlugin ;
- Now, every message of at least level
error
will be sent to the configured slack channel.
Configuration Options:
- The following properties can be provided during instantiation:
webhook
(required): The url provided by slackchannel
(required): The channel you want messages sent tousername
(required): The username you want to use for these slack messageslogLevel
: The minimum log level. See here for all available log levelslevelChannels
: An object containing keys as log levels and channel names for those log levels. This allows you to send logs of different levels to different channels.
{ "fatal": "#general", "error": "#errors" }
Alternative Usage:
- You can also choose what messages to send to slack on a per-message basis like so:
const Logger = ;const SlackPlugin = ; const slackPlugin = webhook: 'https://hooks.slack.com/services/your/webhook' channel: '#api-errors' username: 'API'; const log = plugins: slackPlugin ; log;
- You can prevent certain messages from getting sent to slack by setting
notifySlack
tofalse