mamitech/tikus
最新稳定版本:v4.0.0
Composer 安装命令:
composer create-project mamitech/tikus
包简介
An abstract layer for remote error reporting
README 文档
README
Add Tikus to report your errors to remote error reporting systems such as Bugsnag and Sentry.
This library supports PHP 7.4+.
Installation
Merge this into your composer.json
... "require": { "mamitech/tikus": "^1.0" } ... "repositories": [ { "type": "vcs", "url": "https://github.com/mamitech/tikus.git" } ], ...
Run the command below:
composer update mamikos/tikus
Register tikus service provider in providers array in config/app.php before your AppServiceProvider::class:
'providers' => [ // ... Mamikos\Tikus\Facades\TikusFacade::class, // ... ],
Register an alias in config/app.php:
'aliases' => [ // ... 'Tikus' => Mamikos\Tikus\Facades\TikusFacade::class, ],
Put this code in report method of app/Exceptions/Handler.php
use Tikus; ... public function report(Exception $exception) { if ($this->shouldReport($exception)) { Tikus::reportException($exception); } parent::report($exception); }
To use the configured Bugsnag client, import an alias each time:
use Tikus; Tikus::reportException($e);
Basic configuration
Configure your Bugsnag or Sentry keys in your .env file:
BUGSNAG_API_KEY=your-api-key-here
SENTRY_ENVIRONMENT="${APP_ENV}"
SENTRY_LARAVEL_DSN=your-sentry-dsn
Methods
reportException(Throwable $throwable, Array $metadata = [])
- throwable: Any Throwable, Any Exception
- metadata: metadata in array
Usage
use Tikus; ... catch (Exception $e) { Tikus::reportException($e); }
Tikus::reportException(new Exception('Data not found'), [ 'data_id': $data->id ]);
reportError($name, $message, Array $metadata = [])
- name: error type
- message: error message
- metadata: metadata in array
Usage
use Tikus; Tikus::reportError('Info', 'Data is expired'); Tikus::reportError('Info', 'Data is expired', ['expired_at': '2022-07-01 12:59:00']); // supports nested array Tikus::reportError('Info', 'My wishlist is', [ 'wishlist': [ 'game': 'overwatch 2', 'movie': 'topgun: maverick' ] ]);
统计信息
- 总下载量: 2.86k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-08-19