Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

winston-telegram

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

winston-telegram

A Telegram transport for winston

  • 0.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.2K
decreased by-16.06%
Maintainers
1
Weekly downloads
 
Created
Source

winston-telegram

NPM

A Telegram transport for winston.

Installation

$ npm install winston
$ npm install winston-telegram

Usage

var winston = require('winston');

/*
 * Requiring `winston-telegram` will expose
 * `winston.transports.Telegram`
 */
require('winston-telegram').Telegram;

winston.add(winston.transports.Telegram, options);

Options are the following:

  • token: The Telegram bot authentication token. [required]
  • chatid: The chatid you want to send to. [required]
  • level: Level of messages that this transport should log. [optional] [default info]
  • unique: Whether to log only the declared level and none above. [boolean] [optional]
  • silent: Whether to suppress output. [boolean] [optional]
  • disable_notification: Sends the message silently. [boolean] [optional]
  • template: Format output message. [optional]

String template is based on named arguments:

'{level}' -> level of messages
'{message}' -> text of messages

Examples

Using the Default Logger

var winston = require('winston');

require('winston-telegram').Telegram;

winston.add(winston.transports.Telegram, {
		token : 'TELEGRAM_TOKEN',
		chatid : 'CHAT_ID',
		level : 'error',
		unique : true	
    });

winston.log('error', 'Heeere’s Johnny!');

Multiple transports, different chats, different options

var winston = require('winston');

require('winston-telegram').Telegram;

var logger = new (winston.Logger)({
	transports: [
		new (winston.transports.Telegram)({
			name: 'error-channel',
			token : 'TELEGRAM_TOKEN',
			chatid : 'CHAT_ID_1',
			level : 'error',
			unique : true	
		}),
		new (winston.transports.Telegram)({
			name: 'info-channel',
			token : 'TELEGRAM_TOKEN',
			chatid : 'CHAT_ID_2',
			level : 'info',
			unique : true,
			disable_notification: true
		})
	]
});

logger.error('All work and no play makes Jack a dull boy.');
logger.info('Come play with us, Danny. Forever... and ever... and ever.');

Using template output:

var winston = require('winston');

require('winston-telegram').Telegram;

winston.add(winston.transports.Telegram, {
		token : 'TELEGRAM_TOKEN',
		chatid : 'CHAT_ID',
		level : 'error',
		unique : true,
		template : '[{level}] [{message}]'
    });

winston.log('error', 'Redrum. Redrum. Redrum.');

//Output: [error] [Redrum. Redrum. Redrum.]

Keywords

FAQs

Package last updated on 26 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc