@livy/slack-webhook-handler
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

@livy/slack-webhook-handler

This Livy handler sends log records to Slack through notifications.


Synchronous logger support: no

Runtime: Node.js


Basic Example

const { SlackWebHookHandler } = require('@livy/slack-webhook-handler')

const handler = new SlackWebHookHandler('https://example.com/logs')

Installation

Install it via npm:

npm install @livy/slack-webhook-handler

Options

The first argument to this handler's constructor is the Slack webhook URL to send logs to.

An object of options can be passed as the second argument.

The following options are available:

bubble

Type: boolean

Default: true

Description: Controls whether records handled by this handler should bubble up to other handlers.

See also: Bubbling

channel

Type: string

Description: Slack channel (encoded ID or name)

excludedFields

Type: string[]

Default: []

Description: A dot separated list of fields to exclude from slack message. E.g. ['context.field1', 'extra.field2'].

formatter

Type: FormatterInterface

Default: new LineFormatter() (pre-configured to respect includeContextAndExtra)

Description: The formatter to use.

iconEmoji

Type: string

Description: The emoji name to use

includeContextAndExtra

Type: boolean

Default: false

Description: Whether the attachment should include context and extra data from a log record

level

Type: LogLevel

Default: 'critical'

Description: Controls which log records should be handled based on their log level.

useAttachment

Type: boolean

Default: true

Description: Whether the message should be added to Slack as attachment (plain text otherwise).

username

Type: string

Description: Name of a bot to deliver the message.

useShortAttachments

Type: boolean

Default: false

Description: Whether the the context/extra messages added to Slack as attachments should be in short style.

Public API

bubble

Controls whether records handled by this handler should bubble up to other handlers. Initially set through the bubble option.

See also: Bubbling

defaultFormatter (read-only)

The formatter used by this handler if no formatter option is set.

formatter

This handler supports formatters by implementing the FormattableHandlerInterface.

slackRecord (read-only)

Get the SlackRecord instance associated with the handler.

level

The minimum log level of a log record to be considered by this handler. Initially set through the level option.

processors

This handler supports processors by implementing the ProcessableHandlerInterface.

reset()

This handler implements the ResettableInterface. Resetting it resets all attached processors.

You usually don't want to call this method manually on an individual handler. Consider calling it on the logger instead.

webhookUrl (read-only)

Get the Slack webhook URL of the handler.

Package Sidebar

Install

npm i @livy/slack-webhook-handler

Weekly Downloads

24

Version

1.0.3

License

MIT

Unpacked Size

30.8 kB

Total Files

9

Last publish

Collaborators

  • loilo