From ca62397cbb7e38465716b244078228aaa1096016 Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Sat, 14 Jan 2017 01:47:46 +0300 Subject: [PATCH] composer require unreal4u/monolog-telegram. Telegram Monolog handler added. --- app/config/config_prod.yml | 4 ++ app/config/parameters.yml.dist | 2 + composer.json | 3 +- composer.lock | 53 ++++++++++++++++++- .../Resources/config/services.yml | 21 ++++++-- 5 files changed, 77 insertions(+), 6 deletions(-) diff --git a/app/config/config_prod.yml b/app/config/config_prod.yml index 19ff1a4..c6ee1ec 100644 --- a/app/config/config_prod.yml +++ b/app/config/config_prod.yml @@ -19,5 +19,9 @@ monolog: path: "%kernel.logs_dir%/%kernel.environment%.log" max_files: 30 level: debug + telegram: + type: service + id: app.log.telegram_handler + action_level: error console: type: console diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index 9f6af9d..03dd404 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist @@ -35,3 +35,5 @@ parameters: # Telegram bot telegram_token: "123456:some-token" telegram_max_connections: 2 + # Telegram monolog handler + telegram_log_chat_id: ~ diff --git a/composer.json b/composer.json index 0afce1a..cf8531b 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,8 @@ "knplabs/knp-markdown-bundle": "^1.4", "knplabs/knp-paginator-bundle": "^2.5", "unreal4u/telegram-api": "^2.2", - "csa/guzzle-bundle": "^2.1" + "csa/guzzle-bundle": "^2.1", + "unreal4u/monolog-telegram": "^0.2.0" }, "require-dev": { "sensio/generator-bundle": "^3.0", diff --git a/composer.lock b/composer.lock index 6785223..ba724d8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "9b374e1b2cb413fbab3f0633d6f81c1a", + "content-hash": "88274224cc9dfe36d847acf69d5924d8", "packages": [ { "name": "csa/guzzle-bundle", @@ -3181,6 +3181,57 @@ ], "time": "2017-01-11T19:39:01+00:00" }, + { + "name": "unreal4u/monolog-telegram", + "version": "v0.2", + "source": { + "type": "git", + "url": "https://github.com/unreal4u/monolog-telegram.git", + "reference": "13c34ac16e9dad06e632ca8ed8aeee2d44663e5c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/unreal4u/monolog-telegram/zipball/13c34ac16e9dad06e632ca8ed8aeee2d44663e5c", + "reference": "13c34ac16e9dad06e632ca8ed8aeee2d44663e5c", + "shasum": "" + }, + "require": { + "monolog/monolog": "~1.17", + "php": ">=7.0.0", + "unreal4u/telegram-api": "~2.1" + }, + "require-dev": { + "phpmd/phpmd": "@stable", + "phpunit/phpunit": "@stable", + "squizlabs/php_codesniffer": "@stable" + }, + "type": "library", + "autoload": { + "psr-4": { + "unreal4u\\": "src/unreal4u" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Camilo Sperberg", + "email": "me@unreal4u.com", + "homepage": "https://github.com/unreal4u/monolog-telegram/graphs/contributors" + } + ], + "description": "Monolog handler to enable sending messages through Telegram", + "keywords": [ + "api", + "monolog", + "monolog handler", + "telegram", + "telegram bot" + ], + "time": "2016-12-14T00:25:05+00:00" + }, { "name": "unreal4u/telegram-api", "version": "v2.3.0", diff --git a/src/Skobkin/Bundle/PointToolsBundle/Resources/config/services.yml b/src/Skobkin/Bundle/PointToolsBundle/Resources/config/services.yml index afbfaa6..dee233c 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Resources/config/services.yml +++ b/src/Skobkin/Bundle/PointToolsBundle/Resources/config/services.yml @@ -186,15 +186,28 @@ services: # Telegram services - # API client - app.telegram.api_client: + # Bot API client + app.telegram.bot_client: class: unreal4u\TelegramAPI\TgLog arguments: ['%telegram_token%', '@logger', '@app.http.telegram_client'] + # Logger API client + app.telegram.logger_client: + class: unreal4u\TelegramAPI\TgLog + arguments: ['%telegram_token%', null, '@app.http.telegram_client'] + + # Monolog handler + app.log.telegram_handler: + class: unreal4u\MonologHandler + arguments: + - '@app.telegram.logger_client' + - '%telegram_log_chat_id%' + - 'error' + # Message sender app.telegram.message_sender: class: Skobkin\Bundle\PointToolsBundle\Service\Telegram\MessageSender - arguments: ['@app.telegram.api_client', '@twig'] + arguments: ['@app.telegram.bot_client', '@twig'] # User notifier app.telegram.notifier: @@ -212,7 +225,7 @@ services: app.telegram.inline_query_processor: class: Skobkin\Bundle\PointToolsBundle\Service\Telegram\InlineQueryProcessor lazy: true - arguments: ['@app.point.user_repository', '@app.telegram.api_client'] + arguments: ['@app.point.user_repository', '@app.telegram.bot_client'] # Private message processor app.telegram.private_message_processor: