2017 © Pedro Peláez
 

yii2-extension yii2-logger

Log application errors in slack channel

image

apollo11/yii2-logger

Log application errors in slack channel

  • Wednesday, July 4, 2018
  • by arboshiki
  • Repository
  • 4 Watchers
  • 10 Stars
  • 109 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 2 Open issues
  • 4 Versions
  • 15 % Grown

The README.md

Yii2 Custom Logger

Sending Yii2 application logs to different targets asynchronously or synchronously., (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist apollo11/yii2-logger "~1.0"

or add, (*4)

"apollo11/yii2-logger": "~1.0"

to the require section of your composer.json file., (*5)

The package offers:, (*6)

  1. Abstract Target 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 channel

Basic Usage

The package supports three target classes: EmailTarget, SlackTarget, DbTarget., (*7)

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., (*8)

EmailTarget and DbTarget work pretty much in the simillar way as it is described in Yii Documentation., (*9)

Add the following code to your project configuration file under components -> log -> targets, (*10)

'class' => <Target 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

'class' => apollo11\logger\SlackTarget::class,
'except' => ['yii\web\HttpException:*', 'yii\web\HeadersAlreadySentException'],
'webhookUrl' => <Slack channel webhook url>,
'icon_url' => '<Slack sender icon url>',
'icon_emoji' => '<Slack sender icon emoji>', // If both, icon_url and icon_emoji is provided system will use icon_emoji
'levels' => ['error', 'warning'],
'title_link' => '<Url which will be opened when clicking on title of the slack message>',
'async' => true,
'consoleAppPath' => Yii::getAlias('@console/yii'),
'username' => '<Username which will be used as sender on slack channer>',
'excludeKeys' => [],

Important

If you set async property to true, you must add the following code into your console application controllerMap, (*11)

'async' => [
    'class' => \apollo11\logger\AsyncController::class,
],

The Versions

04/07 2018

dev-master

9999999-dev

Log application errors in slack channel

  Sources   Download

Apache-2.0

The Requires

 

by Zura Tevdoradze

extension yii2

20/04 2018

v1.2.0

1.2.0.0

Log application errors in slack channel

  Sources   Download

Apache-2.0

The Requires

 

by Zura Tevdoradze

extension yii2

04/04 2018

v1.1.0

1.1.0.0

Log application errors in slack channel

  Sources   Download

Apache-2.0

The Requires

 

by Zura Tevdoradze

extension yii2

04/04 2018

v1.0.0

1.0.0.0

Log application errors in slack channel

  Sources   Download

Apache-2.0

The Requires

 

by Zura Tevdoradze

extension yii2