New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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 - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

14

lib/winston-telegram.js

@@ -24,2 +24,6 @@ /*

}
if (options.formatMessage && typeof options.formatMessage !== 'function'){
throw new Error('winston-telegram \'formatMessage\' property should be function');
}
this.token = options.token;

@@ -34,2 +38,3 @@ this.chatId = options.chatId;

this.template = options.template || '[{level}] {message}';
this.formatMessage = options.formatMessage;
this.batchingDelay = options.batchingDelay || 0;

@@ -70,4 +75,11 @@ this.batchingSeparator = options.batchingSeparator || "\n\n";

var messageText = format(this.template,{level : level, message : msg, metadata : meta});
var messageText = null;
var formatOptions = {level : level, message : msg, metadata : meta};
if (this.formatMessage) {
messageText = this.formatMessage(formatOptions)
} else {
messageText = format(this.template, formatOptions)
}
if (this.batchingDelay) {

@@ -74,0 +86,0 @@ this.batchedMessages.push(messageText);

2

package.json
{
"name": "winston-telegram",
"description": "A Telegram transport for winston",
"version": "1.2.1",
"version": "1.3.0",
"author": "Ivan Marban",

@@ -6,0 +6,0 @@ "repository": {

@@ -35,3 +35,4 @@ # winston-telegram

* __disableNotification:__ Sends the message silently. *[boolean]* *[optional]*
* __template:__ Format output message. *[optional]*
* __template:__ Format output message. *[string]* *[optional]*
* __formatMessage:__ Format output message by own method. *[function]* *[optional]*
* __handleExceptions:__ Handle uncaught exceptions. *[boolean]* *[optional]*

@@ -118,2 +119,28 @@ * __batchingDelay:__ Time in ms within which to batch messages together. *[integer]* *[optional]* *[default 0 or disabled]*

Using custom format message:
```js
var winston = require('winston');
require('winston-telegram').Telegram;
winston.add(winston.transports.Telegram, {
token : 'TELEGRAM_TOKEN',
chatId : 'CHAT_ID',
level : 'error',
unique : true,
formatMessage : function(opts) {
var message = opts.message;
if (opts.level === 'warn') {
message += '[Warning] ';
}
return message;
}
});
winston.warn('Some warning!!');
//Output: [Warning] Some warning!!
```
Using batching of messages to avoid exceeding rate limits:

@@ -164,2 +191,9 @@ ``` js

### v1.3.0 (2018/05/03)
- [#10](https://github.com/ivanmarban/winston-telegram/pull/10) Add formatMessage property ([@noveogroup-amorgunov][6])
### v1.2.1 (2017/07/26)
- [#9](https://github.com/ivanmarban/winston-telegram/pull/9) Add error description in case of error ([@dutu][5])
- Update sf library
### v1.2.0 (2017/03/06)

@@ -200,2 +234,4 @@ - [#8](https://github.com/ivanmarban/winston-telegram/pull/8) Add batching of messages sent within a certain interval ([@JustinOng][4])

[3]: https://github.com/alberto467
[4]: https://github.com/JustinOng
[4]: https://github.com/JustinOng
[5]: https://github.com/dutu
[6]: https://github.com/noveogroup-amorgunov
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