Skip to content

Commit

Permalink
Merge branch 'release/v2.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmarban committed May 31, 2020
2 parents 5bd0987 + 1d97c3d commit c488860
Show file tree
Hide file tree
Showing 6 changed files with 1,978 additions and 1,165 deletions.
43 changes: 42 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,72 +7,113 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [v2.3.0] - 2020-05-31
### Added
- [#17](https://github.com/ivanmarban/winston-telegram/pull/17) [#19](https://github.com/ivanmarban/winston-telegram/pull/19) Parse mode support for messages.

## [v2.2.2] - 2019-12-11
### Removed
- Drop node v6 from Travis CI

## [v2.2.1] - 2019-12-11
### Fixed
- [#16](https://github.com/ivanmarban/winston-telegram/issues/16) Use `Buffer.byteLength` to compute the `Content-Length` header.

## [v2.2.0] - 2019-08-06
### Added
- [#13](https://github.com/ivanmarban/winston-telegram/pull/13) Add typescript typings. ([@Multivit4min](https://github.com/Multivit4min))

### Changed
- Update dependencies.

## [v2.1.0] - 2019-06-22
### Changed
- Replace [Request](https://github.com/request/request) by standard https Node.js lib.

### Fixed
- Fix examples.

## [v2.0.1] - 2019-04-28
### Added
- Code style: ESLint + Standard + Prettier.
- Test coverage.
- Documenting with JSDoc.

### Changed
- Removed silent callback since Winston >= 3 takes care of it while using silent option.

## [v2.0.0] - 2019-01-07
### Added
- `winston@3` support.

## [v1.3.1] - 2019-01-07
### Fixed
- [#12](https://github.com/ivanmarban/winston-telegram/pull/12) Fix comments. ([@is2ei](https://github.com/is2ei))

### Changed
- Update dependencies.

## [v1.3.0] - 2018-05-03
### Added
- [#10](https://github.com/ivanmarban/winston-telegram/pull/10) Add formatMessage property. ([@noveogroup-amorgunov](https://github.com/noveogroup-amorgunov))

## [v1.2.1] - 2017-07-26
### Added
- [#9](https://github.com/ivanmarban/winston-telegram/pull/9) Add error description in case of error. ([@dutu](https://github.com/dutu))

### Changed
- Update sf library.

## [v1.2.0] - 2017-06-03
### Added
- [#8](https://github.com/ivanmarban/winston-telegram/pull/8) Add batching of messages sent within a certain interval. ([@JustinOng](https://github.com/JustinOng))

## [v1.1.0] - 2017-05-02
### Added
- [#7](https://github.com/ivanmarban/winston-telegram/pull/7) Use metadata information in messages. ([@alberto467](https://github.com/alberto467))

### Changed
- [#7](https://github.com/ivanmarban/winston-telegram/pull/7) Replace built-in format function by sf node module. ([@alberto467](https://github.com/alberto467))
- Update dependencies.

## [v1.0.0] - 2016-12-05
### Added
- [#6](https://github.com/ivanmarban/winston-telegram/pull/6) Add optional handleExceptions param. ([@speedone](https://github.com/speedone))
- Node.js coding style.

### Changed
- Change option properties for matching coding style.

## [v0.4.0] - 2016-09-26
### Added
- [#5](https://github.com/ivanmarban/winston-telegram/issues/5) Add message template option.

### Changed
- Update dependencies.

### Removed
- Remove peer dependecies.

## [v0.3.0] - 2016-07-17
### Added
- [#2](https://github.com/ivanmarban/winston-telegram/issues/2) Allow multiple transports, send messages silently.

### Changed
- Update dependencies.

## [v0.2.1] - 2016-03-30
### Fixed
- Fix typos.

## [v0.2.0] - 2016-03-08
### Added
- [#1](https://github.com/ivanmarban/winston-telegram/issues/1) Add log level option.

## [v0.1.0] - 2015-11-12
- First version.

[unreleased]: https://github.com/ivanmarban/winston-telegram/compare/v2.2.2...develop
[unreleased]: https://github.com/ivanmarban/winston-telegram/compare/v2.3.0...develop
[v2.3.0]: https://github.com/ivanmarban/winston-telegram/compare/v2.2.2...v2.3.0
[v2.2.2]: https://github.com/ivanmarban/winston-telegram/compare/v2.2.1...v2.2.2
[v2.2.1]: https://github.com/ivanmarban/winston-telegram/compare/v2.2.0...v2.2.1
[v2.2.0]: https://github.com/ivanmarban/winston-telegram/compare/v2.1.0...v2.2.0
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ logger.add(new TelegramLogger(options))
Options:

* __token:__ The Telegram bot authentication token. *[required]*
* __chatId:__ The chatid you want to send to. *[required]*
* __chatId:__ The Telegram chatid you want to send to. *[required]*
* __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]*
Expand Down Expand Up @@ -71,3 +72,4 @@ $ node examples/default-logger.js
[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
10 changes: 6 additions & 4 deletions lib/winston-telegram.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ declare namespace WinstonTelegram {
export interface Options {
/** The Telegram bot authentication token. */
token: string
/** The chatid you want to send to. */
/** The Telegram chatid you want to send to. */
chatId: number
/** The Telegram mode for parsing entities in the message text. */
parseMode: string
/** Level of messages that this transport should log. (default "info") */
level?: string
/** Handle uncaught exceptions. (default false) */
handleExceptions?: boolean
/** Whether to log only the declared level and none above. (default false) */
unique?: boolean
/** Whether to suppress output. (default false) */
Expand All @@ -26,6 +26,8 @@ declare namespace WinstonTelegram {
template?: string
/** Format output message by own method. */
formatMessage?: (params: WinstonTelegram.FormatOptions) => string
/** Handle uncaught exceptions. (default false) */
handleExceptions?: boolean
/** Time in ms within which to batch messages together. (default = 0) (0 = disabled) */
batchingDelay?: number
/** String with which to join batched messages with (default "\n\n") */
Expand All @@ -40,4 +42,4 @@ declare namespace WinstonTelegram {

}

export default WinstonTelegram
export default WinstonTelegram
7 changes: 5 additions & 2 deletions lib/winston-telegram.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ const Transport = require('winston-transport')
/**
* @constructs
* @param {object} options - Options.
* @param {string} options.token - Telegram bot authentication token.
* @param {string} options.token - Telegram bot authentication token.
* @param {string} options.chatId - Telegram unique identifier for chat.
* @param {string} [options.parseMode=''] - Telegram mode for parsing entities in the message text.
* @param {string} [options.level='info'] - Level of messages that this transport should log.
* @param {boolean} [options.handleExceptions=false] - Handling Uncaught Exceptions with winston.
* @param {boolean} [options.unique=false] - Whether to log only the declared level and none above.
Expand All @@ -39,6 +40,7 @@ module.exports = class Telegram extends Transport {

this.token = options.token
this.chatId = options.chatId
this.parseMode = options.parseMode || ''
this.level = options.level || 'info'
this.handleExceptions = options.handleExceptions || false
this.unique = options.unique || false
Expand Down Expand Up @@ -109,7 +111,8 @@ module.exports = class Telegram extends Transport {
const requestData = JSON.stringify({
chat_id: this.chatId,
text: messageText,
disable_notification: this.disableNotification
disable_notification: this.disableNotification,
parse_mode: this.parseMode
})

const options = {
Expand Down
Loading

0 comments on commit c488860

Please sign in to comment.