demi / yii1-bugsnag
Yii1 bugsnag 错误处理器
1.0.7
2016-06-14 18:05 UTC
Requires
- php: >=5.1.0
- bugsnag/bugsnag: 2.*
- yiisoft/yii: 1.1.*
README
Yii1 bugsnag 错误处理器
安装
运行
composer require "demi/yii1-bugsnag" "~1.0"
配置
/protected/config/main.php
<?php return [ 'components' => [ 'bugsnag' => [ 'class' => '\demi\bugsnag\yii1\BugsnagComponent', 'bugsnagApiKey' => '<YOU API KEY>', 'notifyReleaseStages' => ['production', 'development'], 'projectRoot' => realpath(__DIR__ . '/../..'), ], 'log' => [ 'class' => 'CLogRouter', 'routes' => [ [ 'class' => '\demi\bugsnag\yii1\BugsnagLogRoute', 'levels' => 'error, warning', ], ], ], ], ];
/protected/config/console.php
<?php $mainConfig = require(dirname(__FILE__) . '/main.php'); return [ 'components' => [ 'errorHandler' => [ 'class' => '\demi\bugsnag\yii1\BugsnagErrorHandler', ], 'bugsnag' => $mainConfig['components']['bugsnag'], 'log' => [ 'class' => 'CLogRouter', 'routes' => [ [ 'class' => '\demi\bugsnag\yii1\BugsnagLogRoute', 'levels' => 'error, warning', ], ], ] ], ];
示例
<?php // log exception Yii::app()->bugsnag->notifyException(\Exception $e); // log message Yii::app()->bugsnag->notifyError('TestErrorName', 'Example warning message!', ['foo' => 'bar'], 'warning'); // or native exception throw \Exception('Example exception message'); // or native log message Yii::log('Example warning message!', 'warning', 'application.error');