All Projects → TheAppleFreak → winston-slack-webhook-transport

TheAppleFreak / winston-slack-webhook-transport

Licence: MIT license
A Slack transport for Winston 3 that logs to a channel via webhooks

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to winston-slack-webhook-transport

winston-telegram
A Telegram transport for winston
Stars: ✭ 28 (+33.33%)
Mutual labels:  winston-transport, winston3
slack-logger
Slack logger that sends pretty formatted messages to a Slack channel.
Stars: ✭ 15 (-28.57%)
Mutual labels:  winston
nuxt-winston-log
Nuxt module for logging SSR errors using winston
Stars: ✭ 41 (+95.24%)
Mutual labels:  winston
chathooks
Service to convert webhook messages to your favorite chat / team messaging format. Run transparently as a formatting webhook proxy.
Stars: ✭ 39 (+85.71%)
Mutual labels:  slack-webhook
koa2-winston
koa2 version winston logger like express-winston
Stars: ✭ 37 (+76.19%)
Mutual labels:  winston
hapi-good-winston
A good reporter to send and log events with winston
Stars: ✭ 21 (+0%)
Mutual labels:  winston
screeps notify
Send messages (SMS, Slack) from inside Screeps Scripts
Stars: ✭ 21 (+0%)
Mutual labels:  slack-webhook
slackr
Simple shell command to send or pipe content to slack via webhooks. (To upload snippets or files use: www.github.com/a-sync/slackfu)
Stars: ✭ 41 (+95.24%)
Mutual labels:  slack-webhook
slackbridge
Bridging Slack.com #channels between companies
Stars: ✭ 27 (+28.57%)
Mutual labels:  slack-webhook
go-track
URL monitor written in Go that integrates with Slack for notification purposes.
Stars: ✭ 17 (-19.05%)
Mutual labels:  slack-webhook
geoslack
📍 Geolocate your team in Slack
Stars: ✭ 18 (-14.29%)
Mutual labels:  slack-webhook
nodejs-tips
nodejs学习及工作中的一些小技巧和小知识点的总结
Stars: ✭ 22 (+4.76%)
Mutual labels:  winston
logs-winston
Apex Logs integration for the Node.js Winston logging framework
Stars: ✭ 22 (+4.76%)
Mutual labels:  winston-transport
nestlogger
Logger library for NestJs services
Stars: ✭ 28 (+33.33%)
Mutual labels:  winston
rest-api-node-typescript
This is a simple REST API with node and express with typescript
Stars: ✭ 154 (+633.33%)
Mutual labels:  winston
graphscript
A GraphQL Boilerplate with Typescript and TypeORM ⚡
Stars: ✭ 27 (+28.57%)
Mutual labels:  winston
TypeScript-in-Nodejs-Starter
A starter kit for Node.js project written with TypeScript.
Stars: ✭ 39 (+85.71%)
Mutual labels:  winston
winston-dev-console
Winston@3 console format aimed to improve development UX
Stars: ✭ 88 (+319.05%)
Mutual labels:  winston
nodejs-logging-winston
Node.js client integration between Stackdriver Logging and Winston.
Stars: ✭ 87 (+314.29%)
Mutual labels:  winston
typescript-api-starter
🔰 Starter for Node.js express API in Typescript 🚀
Stars: ✭ 72 (+242.86%)
Mutual labels:  winston

winston-slack-webhook-transport

A Slack transport for Winston 3+ that logs to a channel via webhooks.

Continuous Integration npm version downloads

Installation

npm install winston winston-slack-webhook-transport

Usage

Set up with transports

const winston = require("winston");
const SlackHook = require("winston-slack-webhook-transport");

const logger = winston.createLogger({
    level: "info",
    transports: [
        new SlackHook({
            webhookUrl: "https://hooks.slack.com/services/xxx/xxx/xxx"
        })
    ]
});

logger.info("This should now appear on Slack");

Set up by adding

const winston = require("winston");
const SlackHook = require("winston-slack-webhook-transport");

const logger = winston.createLogger({});

logger.add(new SlackHook({ webhookUrl: "https://hooks.slack.com/services/xxx/xxx/xxx" }));

Options

Message formatting

winston-slack-webhook-transport supports the ability to format messages using Slack's message layout features. To do this, supply a custom formatter function that returns the requisite object structure to create the desired layout. You can use the Slack Block Kit Builder to quickly and easily prototype advanced layouts using Block Kit.

If for some reason you don't want to send a message to Slack, you can also return false to prevent the log message from being sent.

Note that if you're using Block Kit using either the attachments or blocks keys, the text parameter will function as a fallback for surfaces that do not support Block Kit, such as IRC clients or push notifications. It is recommended to include text when possible in these cases.

const winston = require("winston");
const SlackHook = require("winston-slack-webhook-transport");
 
const logger = winston.createLogger({
    level: "info",
    transports: [
        new SlackHook({
            webhookUrl: "https://hooks.slack.com/services/xxx/xxx/xxx",
            formatter: info => {
                return {
                    text: "This will function as a fallback for surfaces that don't support Block Kit, like IRC clients or mobile push notifications.",
                    attachments: [
                        {
                            text: "Or don't pass anything. That's fine too"
                        }
                    ],
                    blocks: [
                        {
                            type: "section",
                            text: {
                                type: "plain_text",
                                text: "You can pass more info to the formatter by supplying additional parameters in the logger call"
                            }
                        }
                    ]
                }
            }
        })
    ]
});

logger.info("Definitely try playing around with this.")
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].