UNPKG

@athenna/logger

Version:

The Athenna logging solution. Log in stdout, files and buckets.

24 lines (23 loc) 918 B
/** * @athenna/logger * * (c) João Lenon <lenon@athenna.io> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ import { Telegraf } from 'telegraf'; import { Driver } from '#src/drivers/Driver'; import { debug } from '#src/debug'; export class TelegramDriver extends Driver { async transport(level, message) { if (!this.couldBeTransported(level)) { return; } const formatted = this.format(level, message, true); debug('[%s] Transporting logs with parse mode as %s, using %s token and %s chatId.', TelegramDriver.name, this.driverConfig.parseMode, this.driverConfig.token, this.driverConfig.chatId); return new Telegraf(this.driverConfig.token).telegram.sendMessage(this.driverConfig.chatId, formatted, { parse_mode: this.driverConfig.parseMode }); } }