alexcodelab/telegram-logger-errors

Telegram logger errors package laravel

Downloads

8

Stars

0

Version

1.7.3

header

Telegram logger errors

Package for laravel TLE - Telegram logger errors

Latest Stable Version Total Downloads License

bot

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);

}
alexcode-lab

Author

alexcode-lab