@jitesoft/yolog-slack-plugin
v2.0.6
Published
Plugin for @jitesoft/yolog to output logs to slack.
Downloads
39
Readme
Yolog Slack plugin
Plugin for the @jitesoft/yolog
logger to post logs to Slack.
This plugin makes use of the slack WebHooks, hence it is only supported on the server side and not browser.
Usage:
Install with your favorite package manager!
npm i @jitesoft/yolog-slack-plugin --save
yarn add @jitesoft/yolog-slack-plugin
Import and use just as with any other yolog plugin!
import logger from '@jitesoft/yolog';
import SlackPlugin from '@jitesoft/yolog-slack-plugin';
logger.addPlugin(new SlackPlugin('https://webhook/uri'));
The constructor of the slack plugin takes a slack webhook uri, (please check the slack documentation on how to acquire
one of those) and an optional channel with the #
prefix (or user with the @
prefix). If the channel argument is not
set, it will use the default channel set up with the webhook.
Notification
The notification text can be changed with the notificationText
setter. It defaults to A log message with the tag '%s' was logged!
where %s
will be changed the tag name.
You may also add another %s
(check the @jitesoft/sprintf
module for more info about the placeholders) which will be changed to the log message.
Call stack
In case the message is one of the 'higher level' logging types (error, critical, alert or emergency), the call stack (from the yolog #log method as of now) will be printed as an extra section in the message.