Skip to content

ivanmarban/winston-telegram

 
 

Repository files navigation

winston-telegram

NPM

A Telegram transport for winston.

NPM (Tag) NPM Downloads Build Status Dependencies Status JavaScript Style Guide Donate

Installation

$ npm install winston@2
$ npm install winston-telegram@1

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]
  • disableNotification: Sends the message silently. [boolean] [optional]
  • template: Format output message. [string] [optional]
  • formatMessage: Format output message by own method. [function] [optional]
  • handleExceptions: Handle uncaught exceptions. [boolean] [optional]
  • batchingDelay: Time in ms within which to batch messages together. [integer] [optional] [default 0 or disabled]
  • batchingSeparator: String with which to join batched messages with [string] [default '\n\n']

String template is based on named arguments:

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

Examples

Follow below steps to run the examples:

$ git clone git@github.com:ivanmarban/winston-telegram.git -b 1.x --single-branch
$ npm install

Replace TELEGRAM_TOKEN and CHAT_ID with appropiate values, then run whatever example you want:

$ node examples/default-logger.js

Sponsor this project

Packages

No packages published

Contributors 11