uchup07 / laravel-logging-telegram
Custom Telegram Driver for Laravel Logging
Requires
- php: ^7.4|^8.0
- illuminate/support: ^8.0 || ^9.0
- monolog/monolog: ^1.23|^2.0
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.0
README
Custom Logging Laravel for sending log to telegram chat via Bot
Installation
You can install the package via composer:
composer require uchup07/laravel-logging-telegram
Added environment parameters.
TELEGRAM_BOT_TOKEN=token_telegram_bot TELEGRAM_CHAT_ID= TELEGRAM_LOG_LEVEL=error
Create Telegram Bot and get Token
For using this package you need to create Telegram bot
- Go to @BotFather in the Telegram
- Send
/newbot
- Set up name and bot-name for your bot.
- Get token and add it to your .env file (it is written above)
- Go to your bot and send
/start
message
For detail guide about telegram bot @BotFather on telegram
To check Chat ID please check TELEGRAM API getUpdates
Added Config
Add to config/logging.php file new channel:
'telegram' => [ 'driver' => 'custom', 'via' => Uchup07\LaravelLoggingTelegram::class, 'level' => env('TELEGRAM_LOG_LEVEL','error'), ]
If your default log channel is a stack, you can add it to the stack channel like this
'stack' => [ 'driver' => 'stack', 'channels' => ['daily', 'telegram'], ]
Usage
Publish config file and views
php artisan vendor:publish --provider "Uchup07\LaravelLoggingTelegram\LaravelLoggingTelegramServiceProvider"
Telegram Logging Formats
You can choose among two different formats that you can specify in the .env
file like this :
# Use a minimal log template
TELEGRAM_LOG_TEMPLATE = laravel-logging-telegram::minimal
# Or use the backward compatible one (default setting used even without inserting this row)
TELEGRAM_LOG_TEMPLATE = laravel-logging-telegram::default
It is possible to create other blade templates and reference them in the TELEGRAM_LOG_TEMPLATE
entry
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email uchup07@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.