Skip to content

Commit

Permalink
Merge pull request #2 from GrKamil/dev
Browse files Browse the repository at this point in the history
Use config instead of env
  • Loading branch information
grkamil authored Jan 9, 2019
2 parents 71b0cf7 + 320d2b0 commit c87a0bc
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 5 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
}
}
9 changes: 9 additions & 0 deletions config/telegram-logger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

return [
// Telegram logger bot token
'token' => env('TELEGRAM_LOGGER_BOT_TOKEN'),

// Telegram chat id
'chat_id' => env('TELEGRAM_LOGGER_CHAT_ID')
];
4 changes: 2 additions & 2 deletions src/TelegramHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/TelegramLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TelegramLogger
public function __invoke(array $config)
{
return new Logger(
env('APP_NAME'),
config('app.name'),
[
new TelegramHandler($config['level'])
]
Expand Down
32 changes: 32 additions & 0 deletions src/TelegramLoggerServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Logger;

use Illuminate\Support\ServiceProvider;

/**
* Class TelegramLoggerServiceProvider
* @package Logger
*/
class TelegramLoggerServiceProvider extends ServiceProvider
{
/**
* Register bindings in the container.
*
* @return void
*/
public function register()
{
$this->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');
}
}

0 comments on commit c87a0bc

Please sign in to comment.