Simple Telegram logger for node.js.
$ npm install node-telegram-log
-
Create telegram bot and get it's
token
: -
Add bot to group or go to bot's page and
/start
-
Get
chat_id
where bot will send messages. Feel free to use IDBot to getchat_id
const { TelegramLogger } = require('node-telegram-log');
const logger = new TelegramLogger(BOT_TOKEN_ID, CHAT_ID);
// Log some message
logger.log('Hooray! It works');
// Formatted message
/**
* ℹ️ LOG
*
* Hooray! It works
*/
// Or debug
logger.debug('Just debugging it', { canILogObjects: true });
// Formatted message
/**
* ⚙️ DEBUG
*
* Just debugging it
* {
* "canILogObjects": true
* }
*/
// Mention user, who must to pay attention to this message
// Note: @mentions work only if part of message starts with @username
logger.error('@joeberetta', 'Something went wrong:', [1, { formatted: true }, 'wow']);
// Formatted message
/**
* 🆘 ERROR
*
* Something went wrong:
* [1,{"formatted":true},"wow"]
*
* @joeberetta
*/
Joe Beretta
Copyright © 2020, Joe Beretta. Released under the MIT License.