@liutsing/winston-lark-webhook-transport
v0.0.4
Published
A Lark transport for Winston 3 that logs to a channel via webhooks.
Downloads
11
Maintainers
Readme
# @liutsing/winston-lark-webhook-transport
inspired by winston-slack-webhook-transport
A Lark transport for Winston 3+ that logs to a channel via webhooks.
Installation
npm install winston @liutsing/winston-lark-webhook-transport
Usage
Set up with transports
const winston = require('winston')
const LarkHook = require('@liutsing/winston-lark-webhook-transport')
const logger = winston.createLogger({
level: 'info',
transports: [
new LarkHook({
webhookUrl: 'https://open.feishu.cn/open-apis/bot/v2/hook/xxx',
}),
],
})
logger.info('This should now appear on Slack')
Set up by adding
const winston = require('winston')
const LarkHook = require('@liutsing/winston-lark-webhook-transport')
const logger = winston.createLogger({})
logger.add(new LarkHook({ webhookUrl: 'https://open.feishu.cn/open-apis/bot/v2/hook/xxx' }))
Options
webhookUrl
REQUIRED - Slack incoming webhook URL. Follow steps 1 through 3 at this link to create a new webhook if you don't already have one.formatter
- Custom function to format messages with. This function accepts theinfo
object (see Winston documentation) and must return an object with at least one of the following three keys:text
(string),attachments
(array of attachment objects),blocks
(array of layout block objects). These will be used to structure the format of the logged Slack message. By default, messages will use the format of[level]: [message]
with no attachments or layout blocks. A value offalse
can also be returned to prevent a message from being sent to Slack.level
- Level to log. Global settings will apply if left undefined.msgType
- message type. Lark support some message type liketext
,post
, .etc.