winston-mattermost-webhook-transport
v0.0.2
Published
A Mattermost transport for Winston 3 that logs to a channel via webhooks. Fork of winston-mattermost-webhook-transport
Downloads
24
Readme
winston-mattermost-webhook-transport
A Mattermost transport for Winston 3+ that logs to a channel via webhooks. This project is fork of https://github.com/TheAppleFreak/winston-slack-webhook-transport with minor changes
Installation
npm install winston winston-mattermost-webhook-transport
Usage
Set up with transports
const winston = require("winston");
const MattermostHook = require("winston-mattermost-webhook-transport");
const logger = winston.createLogger({
level: "info",
transports: [
new MattermostHook({
webhookUrl: "https://your-mattermost-server.com/hooks/xxx-generatedkey-xxx"
})
]
});
logger.info("This should now appear on Mattermost");
Set up by adding
const winston = require("winston");
const MattermostHook = require("winston-mattermost-webhook-transport");
const logger = winston.createLogger({});
logger.add(new MattermostHook({ webhookUrl: "https://your-mattermost-server.com/hooks/xxx-generatedkey-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).level
- Level to log. Global settings will apply if left undefined.proxy
- Allows specifying a proxy server that gets passed directly down to Axios (Default:undefined
)channel
- Overrides the webhook's default channel. This should be a channel ID. (Default:undefined
)username
- Overrides the webhook's default username. (Default:undefined
)iconEmoji
- An emoji code string to use in place of the default icon. (Interchangeable withiconUrl
) (Default:undefined
)iconUrl
- An icon image URL string to use in place of the default icon. Interchangeable withiconEmoji
. (Default:undefined
)