0.0.2 • Published 3 years ago
winston-mattermost-webhook-transport v0.0.2
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-transportUsage
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
webhookUrlREQUIRED - 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 theinfoobject (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)