@addme/telegram-logger
v1.0.9
Published
A simple Telegram logger for Node.js and TypeScript projects
Maintainers
Readme
@addme/telegram-logger
A simple Telegram logger for Node.js and TypeScript projects.
Send structured notifications (error, info, success) directly to your Telegram chat.
Features
- Send error, info, and success messages to Telegram.
- Includes type, date/time, environment, and message.
- Built for TypeScript and Node.js.
- Easy to integrate.
Environment Variables
Create a .env file in your project root:
TELEGRAM_BOT_TOKEN=your-telegram-bot-token
TELEGRAM_CHAT_ID=your-chat-id
NODE_ENV=productionTELEGRAM_BOT_TOKEN– your Telegram bot tokenTELEGRAM_CHAT_ID– the ID of the chat where messages will be sentNODE_ENV– optional, defaults todevelopment
Usage (TypeScript)
import { TelegramLogger } from "@addme/telegram-logger";
// Create a logger instance
const logger = new TelegramLogger();
// Send messages
logger.error("Database connection failed!");
logger.info("Background job started");
logger.success("User registration completed!");API
new TelegramLogger(options?)
Creates a new Telegram logger instance.
interface TelegramLoggerOptions {
botToken?: string;
chatId?: string;
environment?: string;
}botToken– optional, defaults toprocess.env.TELEGRAM_BOT_TOKENchatId– optional, defaults toprocess.env.TELEGRAM_CHAT_IDenvironment– optional, defaults toprocess.env.NODE_ENV
Methods
logger.error(message: string)– send an error messagelogger.info(message: string)– send an info messagelogger.success(message: string)– send a success message
Example Telegram Output
❌ Notification
Type: ERROR
Date: 10/02/2025, 14:30:00
Environment: production
Message: Database connection failed!License
MIT © addme
