eroteev/yii2-rollbar

Rollbar logging for Yii2 framework

Installs: 39 751

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:yii2-extension

1.0.7 2018-08-31 08:51 UTC

This package is not auto-updated.

Last update: 2024-04-20 12:04:08 UTC


README

Simplified rollbar monitoring integration for Yii2 applications.

Installation

The preferred way to install this extension is through composer.

To install add

"eroteev/yii2-rollbar": "^1.0.0"

to the require section of your composer.json file.

Setup instructions

  1. Add the component configuration in your global config file:
'bootstrap' => ['rollbar'],
'components' => [
    'rollbar' => [
        'class' => 'eroteev\rollbar\Rollbar',
        'config' => [
            'access_token' => 'POST_SERVER_ITEM_ACCESS_TOKEN',
        ]
    ],
],
  1. Add the web error handler configuration in your web config file:
'components' => [
    'errorHandler' => [
        'class' => 'eroteev\rollbar\error_handler\WebErrorHandler'
    ],
],
  1. Add the console error handler configuration in your console config file:
'components' => [
    'errorHandler' => [
        'class' => 'eroteev\rollbar\error_handler\ConsoleErrorHandler'
    ],
],
  1. Add log target in your global config file:
'log' => [
    'targets' => [
        [
            'class' => 'eroteev\rollbar\log\RollbarTarget',
            'levels' => ['error'], // Log levels you want to appear in Rollbar
            'categories' => ['application'],
        ],
    ],
],

Ignore specific exceptions

To ignore specific exceptions you can update the component configuration in your global config file:

'components' => [
    'rollbar' => [
        'class' => 'eroteev\rollbar\Rollbar',
        'config' => [
            // ...
            'check_ignore' => function ($isUncaught, $toLog, $payload) {
                return eroteev\rollbar\helpers\IgnoreExceptionHelper::checkIgnore($toLog, [
                       ['yii\web\HttpException', 'statusCode' => [400, 404]],
                       ['yii\db\Exception', 'getCode' => [2002]],
                   ]
                );
            }
        ]
    ],
],