alexcodelab / telegram-logger-errors
Telegram logger errors package laravel
Fund package maintenance!
martinjack
Patreon
buymeacoffee.com/martinjack
Requires
- php: ^8.1
- illuminate/support: ^8.0 || ^9.0 || ^10.1
- irazasyed/telegram-bot-sdk: ^3.0
This package is auto-updated.
Last update: 2024-04-16 16:16:14 UTC
README
Telegram logger errors
Package for laravel TLE - Telegram logger errors
Read this in other language: English, Русский, Український
Requirements
- php 8.1
- composer
Installation
Run composer require command.
composer require alexcodelab/telegram-logger-errors
Laravel Setting
After updating composer, register the service provider in config\app.php
Telegram\Bot\Laravel\TelegramServiceProvider::class, TLE\TLEServiceProvider::class
Add then alias TLE adding its facade to the aliases array in the same file:
'Telegram' => Telegram\Bot\Laravel\Facades\Telegram::class, 'TLE' => TLE\Facades\TLEFacade::class
Copy file config telegram.php, tle.php in confing folder
Telegram SDK
php artisan vendor:publish
Select Provider: Telegram\Bot\Laravel\TelegramServiceProvider
TLE
php artisan vendor:publish
Select Tag: tle-config
or
php artisan vendor:publish --provider="TLE\TLEServiceProvider" --tag="tle-config"
Setting token and name bot in config/telegram.php
'bots' => [ 'common' => [ 'username' => 'Name bot', 'token' => 'Token bot', 'commands' => [], ], ], 'default' => 'common',
Debug mode
'debug' => false
Name bot
Need for Telegram SDK
'botname' => ''
Chat ID
Chat ID you can get via chat bot @RawDataBot
'chat_id' => ''
Save log
'save_log' => true
Path temporary save file
'path_save' => 'local'
Disable write exception Telegram in log file
'disable_exception_telegram' => false
Usage
Send simple exception
use TLE; try { print_r($a); } catch (\Exception $e) { TLE::exp($e)->send(); }
Send simple exception + information
use TLE; try { print_r($a); } catch (\Exception $e) { TLE::exp($e)->info('Field check')->send(); }
Send Guzzle Exception
use TLE; try { print_r($a); } catch (RequestException $e) { TLE::guzzle($e)->send(); }
Add class TLE in global handler exception in app\Exceptions\Handler.php
public function report(Exception $exception) { \TLE::exp($exception)->send(); parent::report($exception); }