# winston-telegram

> A Telegram transport for winston

Latest version **2.7.0** (published 2024-01-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install winston-telegram
pnpm add winston-telegram
yarn add winston-telegram
bun add winston-telegram
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.7.0 |
| Published | 2024-01-06 |
| First published | 2015-11-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 14.0.0 |
| Dependencies | 1 |
| Unpacked size | 21.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ivan Marban |
| Maintainers | ivanmarban |
| Keywords | logging, sysadmin, tools, winston, telegram, bot |

## Links

- npm: https://www.npmjs.com/package/winston-telegram
- Repository: https://github.com/ivanmarban/winston-telegram
- Homepage: https://github.com/ivanmarban/winston-telegram#readme
- Issues: https://github.com/ivanmarban/winston-telegram/issues
- npm.io page: https://npm.io/package/winston-telegram

## Dependencies (1)

- [winston-transport](https://npm.io/package/winston-transport.md) ^4.3.0

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 2.7.0 (latest) — 2024-01-06
- 1.4.2 (1.x-latest) — 2019-12-11
- 2.6.0 — 2022-05-15
- 2.5.0 — 2021-11-09
- 2.4.1 — 2021-09-26
- 2.4.0 — 2021-09-25
- 2.3.5 — 2021-05-23
- 2.3.4 — 2021-04-02
- 2.3.3 — 2021-01-24
- 2.3.2 — 2020-11-08
- 2.3.1 — 2020-11-07
- 2.3.0 — 2020-05-31
- 2.2.2 — 2019-12-11
- 2.2.1 — 2019-12-11
- 2.2.0 — 2019-08-06
- … 17 more at https://npm.io/package/winston-telegram/versions

## README

# winston-telegram

[![NPM](https://nodei.co/npm/winston-telegram.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/winston-telegram/)

A [Telegram][0] transport for [winston][1].

[![Version npm](https://img.shields.io/npm/v/winston-telegram.svg)](https://www.npmjs.com/package/winston-telegram)
[![npm Downloads](https://img.shields.io/npm/dw/winston-telegram.svg)](https://npmcharts.com/compare/winston-telegram?minimal=true)
[![CI Status](https://github.com/ivanmarban/winston-telegram/actions/workflows/ci.yaml/badge.svg?branch=master)](https://github.com/ivanmarban/winston-telegram/actions/workflows/ci.yaml)
[![Coverage Status](https://coveralls.io/repos/github/ivanmarban/winston-telegram/badge.svg?branch=master)](https://coveralls.io/github/ivanmarban/winston-telegram?branch=master)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## winston-telegram@2

Installation:
``` sh
$ npm install winston@3
$ npm install winston-telegram@2
```

## Looking for `winston-telegram@1.x` ?
Documentation below is for `winston-telegram@2`. [Read the `winston-telegram@1.x` documentation][2].

## Usage
``` js
const logger = require('winston')
const TelegramLogger = require('winston-telegram')

// or
import TelegramLogger from 'winston-telegram';

logger.add(new TelegramLogger(options))
```

Options:

* `token` The Telegram bot authentication token. *[required]*
* `chatId` The Telegram chatid you want to send to. *[required]*
* `messageThreadId` The Telegram unique identifier of a message thread to which the message belongs. *[optional]*
* `parseMode` The Telegram mode for parsing entities in the message text. See [formatting options][4] for more details. *[optional]*
* `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:
``` js
'{level}' -> level of messages
'{message}' -> text of messages
'{metadata}' -> metadata object of messages
```

## Examples

Follow below steps to run the examples:

``` sh
$ git clone git@github.com:ivanmarban/winston-telegram.git -b master --single-branch
$ npm install
```

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

``` sh
$ node examples/default-logger.js
```

[0]: https://telegram.org/
[1]: https://github.com/flatiron/winston
[2]: https://github.com/ivanmarban/winston-telegram/tree/1.x
[3]: https://github.com/ivanmarban/winston-telegram/tree/master/examples
[4]: https://core.telegram.org/bots/api#formatting-options

---
_Source: https://npm.io/package/winston-telegram · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
