This extension allows you to see your project logs in real time using Telegram app.
via Composer require command (composer 2 is required):
Just type into the CLI in your project root:
composer require electrobayan/telegram-logger
via updating composer.json:
{ "require": { "electrobayan/telegram-logger": "^1.0" } }
Then run in you CLI:
composer install
You will have to create a Telegram bot and a channel. Check the user guide here. Then just do the following:
$infoLogger = new \TelegramLogger\Creator\InfoPoster('Telegram Key Goes here', '@your_telegram_channel_name'); $infoLogger->post('test', ['key_1' => 'value_1', 'key_2' => 'value_2'], ['tag1', 'tag2']);
There 3 types of log messages:
- Info
- Warning
- Error
$errorLogger = new \TelegramLogger\Creator\ErrorPoster('Telegram Key Goes here', '@your_telegram_channel_name'); $warningLogger = new \TelegramLogger\Creator\WarningPoster('Telegram Key Goes here', '@your_telegram_channel_name'); $infoLogger = new \TelegramLogger\Creator\InfoPoster('Telegram Key Goes here', '@your_telegram_channel_name');
After the poster created all is left is just to call post
method.
$errorLogger->post('Error Message', ['key_1' => 'value_1', 'key_2' => 'value_2'], ['tag1', 'tag2']); $warningLogger->post('Warning Message', ['key_1' => 'value_1', 'key_2' => 'value_2'], ['tag1', 'tag2']); $infoLogger->post('Info Message', ['key_1' => 'value_1', 'key_2' => 'value_2'], ['tag1', 'tag2']);
Also, you can pass optional extra params if needed as an array key => value
. Both key and value will be posted into the channel.
You can pass optional tags if needed as an array key => value
. Only values will be posted into the channel.