Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/apolloeleven/yii2-logger
Send yii2 logs to slack. Custom Target class. Hide sensitive information before sending.
https://github.com/apolloeleven/yii2-logger
slack-logger yii2-extension yii2-logging
Last synced: 2 months ago
JSON representation
Send yii2 logs to slack. Custom Target class. Hide sensitive information before sending.
- Host: GitHub
- URL: https://github.com/apolloeleven/yii2-logger
- Owner: apolloeleven
- License: apache-2.0
- Created: 2018-02-22T09:45:16.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-11-02T16:11:09.000Z (about 3 years ago)
- Last Synced: 2024-10-10T17:23:08.822Z (3 months ago)
- Topics: slack-logger, yii2-extension, yii2-logging
- Language: PHP
- Homepage:
- Size: 45.9 KB
- Stars: 10
- Watchers: 8
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Yii2 Custom Logger
==================
Sending Yii2 application logs to different targets asynchronously or synchronously.Installation
------------The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require --prefer-dist apollo11/yii2-logger "~1.0"
```or add
```
"apollo11/yii2-logger": "~1.0"
```to the require section of your `composer.json` file.
The package offers:
1. Abstract [Target](https://github.com/apolloeleven/yii2-logger/blob/master/Target.php) class with support of sending messages asynchronously. It also has possibility to hide sensitive information when sending $_POST or other $GLOBALS data to target.
2. Slack target: Sending messages to slack channelBasic Usage
-----
The package supports three target classes: [EmailTarget](https://github.com/apolloeleven/yii2-logger/blob/master/EmailTarget.php), [SlackTarget](https://github.com/apolloeleven/yii2-logger/blob/master/SlackTarget.php), [DbTarget](https://github.com/apolloeleven/yii2-logger/blob/master/DbTarget.php).All target classes have support for sending messages asynchronously and hide passwords(or other sensitive data) provided by user. If you set `async` to `true` than you must provide the `consoleAppPath`.
EmailTarget and DbTarget work pretty much in the simillar way as it is described in [Yii Documentation](https://www.yiiframework.com/doc/guide/2.0/en/runtime-logging).
Add the following code to your project configuration file under `components` -> `log` -> `targets`
```php
'class' => ,
// If async is set to true you have to provide consoleAppPath
'async' => true,
'consoleAppPath' => Yii::getAlias('@console/yii'),
// If you would like to use different php binary, when sending messages asynchronously you can set it from here
// 'phpExecPath' => 'php',
// Provide here keys which will be hidden before sending messages. It is case insensitive
'excludeKeys' => [
'*PASSWORD*', // Will hide all keys from $GLOBALS objects which contains "password".
'*PASSWORD', // Will hide all keys from $GLOBALS objects which ends with "password".
'PASSWORD*', // Will hide all keys from $GLOBALS objects which starts with "password".
],
```### SlackTarget
```php
'class' => apollo11\logger\SlackTarget::class,
'except' => ['yii\web\HttpException:*', 'yii\web\HeadersAlreadySentException'],
'webhookUrl' => ,
'icon_url' => '',
'icon_emoji' => '', // If both, icon_url and icon_emoji is provided system will use icon_emoji
'levels' => ['error', 'warning'],
'title_link' => '',
'async' => true,
'consoleAppPath' => Yii::getAlias('@console/yii'),
'username' => '',
'excludeKeys' => [],
```#### Important
If you set `async` property to true, you must add the following code into your console application `controllerMap````
'async' => [
'class' => \apollo11\logger\AsyncController::class,
],
```