1.1.6 • Published 5 months ago
@wildegor/winston-telegram v1.1.6
Winston-Telegram
A Telegram transport for winston.
Originally forked from ivanmarban/winston-telegram and updated to support winston 3.x and new features.
Main features:
- Send log message to Telegram;
- Send log messages with batching delay;
- Send log messages with custom template;
- Send log messages with custom formatMessage function;
- Send log messages to specific chat;
- Send log messages to specific topic;
- Send log messages with silent mode;
- Send log messages with disable notification;
- Send log messages with custom parse mode;
- Send log messages with custom levels;
- Send log messages with handle exceptions;
- Send log messages with custom batching separator.
Installation:
$ yarn add winston@3
$ yarn add winston-transport@4
$ yarn add axios
$ yarn add @wildegor/winston-telegram@latest
Usage
const logger = require('winston')
const TelegramTransport = require('@wildegor/winston-telegram')
// or
import { TelegramTransport } from '@wildegor/winston-telegram';
logger.add(new TelegramTransport(options))
Options:
- token: The Telegram bot authentication token. required
- chatId: The Telegram chatid you want to send to. optional
- parseMode: The Telegram mode for parsing entities in the message text. See formatting options for more details. optional
- levels: Levels of messages that this transport should log. optional default ALL
- 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:wildegor/winston-telegram.git -b main --single-branch
$ yarn install
Replace TELEGRAM_TOKEN
and CHAT_ID
with appropriate values, then run whatever example you want:
$ cd examples/simple-log # or examples/replace-nest-logger
$ yarn install
$ yarn start:dev
1.1.6
5 months ago
1.1.5
5 months ago
1.1.4
5 months ago
1.1.3
5 months ago
1.1.2
5 months ago
1.1.1
6 months ago
1.1.0
6 months ago
1.0.0
6 months ago
1.0.0-beta.4
6 months ago
1.0.0-beta.3
6 months ago
1.0.0-beta.2
6 months ago