telelog
v1.0.2
Published
Telegram logger built in Node.js
Downloads
2
Maintainers
Readme
Telelog
Lightweight telegram logger built in Node.js
Features
- Send logs from your app to telegram through telegram bot in real-time
- 4 levels of logs based on needs
Installing
$ npm install telelog
- Depends on
axios
- Built with JavaScript
Requirements
- Create a telegram bot and copy its
BOT_TOKEN_ID
- Add the bot to a group
- Get group's
CHAT_ID
by going to https://web.telegram.org and open a group chat. Look at the URL and get the digits behind the character#
- You can also use IDBot to get
CHAT_ID
Usages
// Import the library
import Telelog from 'telelog';
// Initialize the telelog class
const telelog = new Telelog(BOT_TOKEN_ID, CHAT_ID);
// Log some info
telelog.info('Pshhh, this is a secret!');
/*
INFO [DATE] [FILE_LINE]
Pshhh, this is a secret!
*/
// Debug
const a = 8;
telelog.info('Is this thing working? Let me see, the value of a is:', a);
/*
DEBUG [DATE] [FILE_LINE]
Is this thing working? Let me see, the value of a is: 8
*/
// Warn
telelog.warn('Be careful!', 'This is dangerous!');
/*
WARN [DATE] [FILE_LINE]
Be careful! This is dangerous!
*/
// Error
telelog.error('Beep Boop! There is an error. @randomuser');
/*
ERROR [DATE] [FILE_LINE]
Beep Boop! There is an error.
*/
- Mentioning is possible by using @ followed by the telegram handle
- [DATE] will be replaced by the date when the log is produced
- [FILE_LINE] will be replaced by the file name and line which produces the log