From 43da4da68aad38c0fab407a4d04aa01e6358a2db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D0=BC=D0=B8=D0=BB=D1=8C=20=D0=9C=D1=83=D1=85?= =?UTF-8?q?=D0=B0=D0=BC=D0=B5=D1=82=D0=B7=D1=8F=D0=BD=D0=BE=D0=B2?= Date: Wed, 9 Jan 2019 09:49:55 +0300 Subject: [PATCH 1/3] create config, service provider --- composer.json | 11 +++++++-- config/telegram-logger.php | 9 ++++++++ src/TelegramLoggerServiceProvider.php | 32 +++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 config/telegram-logger.php create mode 100644 src/TelegramLoggerServiceProvider.php diff --git a/composer.json b/composer.json index 6bba5e7..a092377 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,14 @@ "monolog/monolog": "^1.23", "laravel/framework": "5.6.*|5.7.*" }, - "version":"0.1.1", + "version":"0.1.2", "minimum-stability": "dev", - "prefer-stable": true + "prefer-stable": true, + "extra": { + "laravel": { + "providers": [ + "Logger\\TelegramLoggerServiceProvider" + ] + } + } } diff --git a/config/telegram-logger.php b/config/telegram-logger.php new file mode 100644 index 0000000..9838fab --- /dev/null +++ b/config/telegram-logger.php @@ -0,0 +1,9 @@ + env('TELEGRAM_LOGGER_BOT_TOKEN'), + + // Telegram chat id + 'chat_id' => env('TELEGRAM_LOGGER_CHAT_ID') +]; \ No newline at end of file diff --git a/src/TelegramLoggerServiceProvider.php b/src/TelegramLoggerServiceProvider.php new file mode 100644 index 0000000..c876867 --- /dev/null +++ b/src/TelegramLoggerServiceProvider.php @@ -0,0 +1,32 @@ +mergeConfigFrom(__DIR__ . '/../config/telegram-logger.php', 'telegram-logger'); + } + + /** + * Perform post-registration booting of services. + * + * @return void + */ + public function boot() + { + $this->publishes([__DIR__ . '/../config/telegram-logger.php' => config_path('telegram-logger.php')], 'config'); + } +} \ No newline at end of file From 8fca3f63439672e37b3350e4845920c84172ff6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D0=BC=D0=B8=D0=BB=D1=8C=20=D0=9C=D1=83=D1=85?= =?UTF-8?q?=D0=B0=D0=BC=D0=B5=D1=82=D0=B7=D1=8F=D0=BD=D0=BE=D0=B2?= Date: Wed, 9 Jan 2019 10:00:15 +0300 Subject: [PATCH 2/3] use config instead of env #1 --- src/TelegramHandler.php | 4 ++-- src/TelegramLogger.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/TelegramHandler.php b/src/TelegramHandler.php index 05a3479..48114b2 100644 --- a/src/TelegramHandler.php +++ b/src/TelegramHandler.php @@ -51,8 +51,8 @@ public function __construct($level) parent::__construct($level, true); // define variables for making Telegram request - $this->botToken = env('TELEGRAM_LOGGER_BOT_TOKEN'); - $this->chatId = env('TELEGRAM_LOGGER_CHAT_ID'); + $this->botToken = config('telegram-logger.token'); + $this->chatId = config('telegram-logger.chat_id'); // define variables for text message $this->appName = config('app.name'); diff --git a/src/TelegramLogger.php b/src/TelegramLogger.php index afe23fd..c0ddac0 100644 --- a/src/TelegramLogger.php +++ b/src/TelegramLogger.php @@ -19,7 +19,7 @@ class TelegramLogger public function __invoke(array $config) { return new Logger( - env('APP_NAME'), + config('app.name'), [ new TelegramHandler($config['level']) ] From 320d2b0c79dfd372276f157f3f5c0aa9c1074514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D0=BC=D0=B8=D0=BB=D1=8C=20=D0=9C=D1=83=D1=85?= =?UTF-8?q?=D0=B0=D0=BC=D0=B5=D1=82=D0=B7=D1=8F=D0=BD=D0=BE=D0=B2?= Date: Wed, 9 Jan 2019 10:10:33 +0300 Subject: [PATCH 3/3] add license, update readme #1 --- LICENSE | 21 +++++++++++++++++++++ README.md | 5 +++++ 2 files changed, 26 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2bd2637 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Darius Matulionis + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index d780844..a4b8ce9 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,11 @@ Or you can simply change the default log channel in the .env LOG_CHANNEL=telegram ``` +Publish config file +``` +php artisan vendor:publish --provider "Logger\TelegramLoggerServiceProvider" +``` + ## Create bot For using this package you need to create Telegram bot