Skip to content

Commit

Permalink
Merge branch 'release/v0.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmarban committed Mar 8, 2016
2 parents 02e8c8b + fec3ae0 commit 7a43ec1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 34 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 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].

## Installation
Expand All @@ -26,6 +28,10 @@ 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]*


[0]: https://telegram.org/
[1]: https://github.com/flatiron/winston
9 changes: 6 additions & 3 deletions lib/winston-telegram.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ var Telegram = exports.Telegram = function (options) {
}
this.token = options.token
this.chatid = options.chatid;
this.level = options.level || 'info';
this.unique = options.unique || false;
this.silent = options.silent || false;
};

/** @extends winston.Transport */
Expand All @@ -44,9 +47,9 @@ util.inherits(Telegram, winston.Transport);
*/
Telegram.prototype.log = function (level, msg, meta, callback) {
var self = this;
if (this.silent) {
return callback && callback(null, true);
}
if (this.silent) return callback(null, true);
if (this.unique && this.level != level) return callback(null, true);

request({
url : 'https://api.telegram.org/bot'+this.token+'/sendMessage',
method : 'POST',
Expand Down
66 changes: 35 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
{
"name": "winston-telegram",
"description": "A Telegram transport for winston",
"version": "0.1.0",
"author": "Ivan Marban",
"repository": {
"type": "git",
"url": "http://github.com/ivanmarban/winston-telegram.git"
},
"keywords": ["logging",
"sysadmin",
"tools",
"winston",
"telegram",
"bot"],
"dependencies": {
"request": "^2.65.0"
},
"devDependencies": {
"winston": ""
},
"peerDependencies": {
"winston": "",
"vows": ""
},
"main": "./lib/winston-telegram",
"scripts": { "test": "vows test/*test.js --spec" },
"engines": {
"node": ">= 0.10.0"
},
"license": "MIT"
}
"name": "winston-telegram",
"description": "A Telegram transport for winston",
"version": "0.2.0",
"author": "Ivan Marban",
"repository": {
"type": "git",
"url": "http://github.com/ivanmarban/winston-telegram.git"
},
"keywords": [
"logging",
"sysadmin",
"tools",
"winston",
"telegram",
"bot"
],
"dependencies": {
"request": "^2.69.0"
},
"devDependencies": {
"winston": ""
},
"peerDependencies": {
"winston": "",
"vows": ""
},
"main": "./lib/winston-telegram",
"scripts": {
"test": "vows test/*test.js --spec"
},
"engines": {
"node": ">= 0.10.0"
},
"license": "MIT"
}

0 comments on commit 7a43ec1

Please sign in to comment.