therealartz / telegram-log-handler
Telegram Handler for Monolog Logger.
v0.1.1
2019-05-18 14:23 UTC
Requires
- php: ^7.1
- ext-curl: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^6.3
- monolog/monolog: ^1.24
This package is auto-updated.
Last update: 2024-12-19 02:56:50 UTC
README
This package provides Handler for Monolog Logger.
For me in some cases it's very convenient to receive logs in Telegram, so I wrote a short handler for using in any project.
Requirements
- PHP 7.1+
- cURL and mbstring extensions activated
Usage
Set up handler
<?php use Monolog\Logger; use TelegramLog\Handler\TelegramHandler; $botToken = 'your-bot-token'; $chatId = '@yourChatId'; $logger = new Logger( 'logger_dev', [ new TelegramHandler($botToken, $chatId) ] ); $logger->info('My logger works!');
Set up handler in Laravel
According to Laravel docs in config/logging.php
add channel:
return [ // ... 'channels' => [ // ... 'telegram' => [ 'driver' => 'monolog', 'handler' => \TelegramLog\Handler\TelegramHandler::class, 'with' => [ 'botToken' => 'your-bot-token', 'chatId' => '@yourChatId', ], ], ], ];
And use by set in .env LOG_CHANNEL=telegram