npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@kevit/winston-channel-logger

v1.0.4

Published

Library to dump winston logs to Business Communication Platforms such as MS Teams, Slack, etc.

Downloads

15

Readme

README

This repository contains a Winston Channel Logger for logging messages to various platforms such as Microsoft Teams, Slack, and Discord. The module utilizes incoming Webhooks and Platform APIs to send messages.

Installation

To install the module into your project, you can use npm or yarn:

npm install @kevit/winston-channel-logger

or

yarn add @kevit/winston-channel-logger

Usage

To use the custom transport module, follow these steps:

  1. Import it into your code as:
import { WinstonChannelLogger } from '@kevit/winston-channel-logger';
  1. Initialize the object of WinstonChannelLogger as:
const winstonChannelLogger = new WinstonChannelLogger({ 
  format: format.uncolorize(),
  level:'log_level',
  platforms: [{
    platformName: 'ms-teams',
    webhookUrl: '<teams-webhook-url>',
  },
    {
      platformName: 'slack',
      token: '<slack-token>',
      channelId: '<slack-channel-id>',
    },
    {
      platformName: 'discord',
      webhookUrl: '<discord-webhook-url>',
    }],
});
  1. Finally, attach this custom logger in transports array of createLogger For ex:
const logger = createLogger({
  transports: [new transports.Console({  level:'silly'}), winstonChannelLogger],
});

In the above configuration one or more channels can be configured by passing channel specific argument Channel specific configuration. Configurations can be made as follows:

Microsoft Teams

  • Value for platformName will be ms-teams.
  • For getting teams-webhook-url , it can be generated as mentioned in the documentation.

Slack

  • Value for platformName will be slack.
  • All the messages will be dumped as threads of the message for a given date.
  • A message will be created with the text as Logs for Date: dd-MM-yyyy. This helps to organise the messages grouped by the Date they are sent.
  • Following configurations will be needed to enable this:
    • Create a Slack App referring this. Choose to build from scratch and select the desired workspace.
    • For getting slack-token:
      • After the app is created, from the Left Navigation Menu, goto OAuth and Permissions tab
      • Under the Scopes section, add channels:read, channels:history, chat:write permissions.
      • Once done, from the same tab, from the OAuth Tokens section generate & copy Bot User OAuth Token and install/reinstall it to the workspace. Select the needful public channel.
      • Use this generated token as slack-token in the configuration of WinstonChannelLogger's object.
    • For getting slack-channel-id:
      • Go to Slack App, from the list of channels, right click on the Public channel for which logger is enabled (same that is allowed in previous step), and select View channel details.
      • Scroll down in popup to get the Channel Id something as shown below: Channel Id

Discord

  • Value for platformName will be discord.
  • For getting discord-webhook-url , it can be generated as mentioned in the documentation.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or a pull request in this repository.

License

This project is licensed under the GNU GENERAL PUBLIC LICENSE.