/node-telegram-logger

Primary LanguageJavaScriptMIT LicenseMIT

Telegram Logger

Simple Telegram logger for node.js.

Install

$ npm install node-telegram-log

Prerequisites

  1. Create telegram bot and get it's token:

  2. Add bot to group or go to bot's page and /start

  3. Get chat_id where bot will send messages. Feel free to use IDBot to get chat_id

Usage

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
 */

Author

Joe Beretta

License

Copyright © 2020, Joe Beretta. Released under the MIT License.