Skip to content

therealartz/telegram-log-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

telegram-log-handler: Monolog handler for sending logs by Telegram bot

Latest Stable Version Total Downloads

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

About

Telegram Handler for Monolog Logger.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages