denchotsanov/yii2-slack-log

Log extension

Installs: 205

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:yii2-extension

1.4 2022-05-20 07:36 UTC

This package is auto-updated.

Last update: 2024-10-20 12:40:07 UTC


README

Installation

The preferred way to install this extension is through composer.

Run

composer require "denchotsanov/yii2-slack-log:^1.0"

or add

"denchotsanov/yii2-slack-log": "^1.0"

to the require section of your composer.json file.

Usage

First set up an incoming webhook integration in your Slack team and obtain a token. It should look like https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX.

Then set the following Yii 2 configuration parameters:

'components' => [
    'log' => [
        'targets' => [
            [
                'class' => 'denchotsanov\slacklog\Slack',
                'webhookUrl' => 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX',
            ],
        ],
    ],
],

Sample config:

'components' => [
    'log' => [
        'targets' => [
            [
                'class' => 'denchotsanov\slacklog\Slack',
                'levels' => ['error'],
                'except' => [
                    'yii\web\HttpException:*',
                ],
                'enabled' => YII_ENV_PROD,
                'webhookUrl' => 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX',
                'username' => 'Alarm Bot',
                'iconEmoji' => ':poop:',
            ],
        ],
    ],
],