Skip to content

holycheater/yii2-sentry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Yii2 Sentry error handler

Config

'components' => [
    'sentry' => [
        'class' => 'alexsalt\sentry\Client',
        'dsn' => '<your_dsn_url>',
        'options' => [
            'exclude' => [
                'yii\\web\\NotFoundHttpException',
                'yii\\web\\ForbiddenHttpException',
                'yii\\web\\UnauthorizedHttpException',
                'yii\\base\\InvalidRouteException',
            ],
        ],
    ],
    'errorHandler' => [
        'class' => 'alexsalt\sentry\ConsoleErrorHandler',
    ],
    'log' => [
        'targets' => [
            [
                'class' => 'alexsalt\\sentry\\LogTarget',
                'levels' => [ 'warning', 'error' ],
            ],
        ],
    ],
]

Use alexsalt\sentry\WebErrorHandler for web apps

Logging

// basic
Yii::error('message');
// extra data
Yii::error([
    'msg' => 'message name',
    'data' => [
        'foo' => 'bar',
    ],
]);
// capture exception
try {
    throw new \Exception('test');
} catch (\Exception $e) {
    Yii::$app->errorHandler->logException($e);
}