项目作者: faultline

项目描述 :
faultline exception and error notifier for PHP.
高级语言: PHP
项目地址: git://github.com/faultline/faultline-php.git
创建时间: 2016-12-08T11:56:25Z
项目社区:https://github.com/faultline/faultline-php

开源协议:

下载


faultline-php Travis

faultline exception and error notifier for PHP.

Installation

  1. $ composer require faultline/faultline

Usage

  1. // Create new Notifier instance.
  2. $notifier = new Faultline\Notifier([
  3. 'project' => 'faultline-php',
  4. 'apiKey' => 'xxxxXXXXXxXxXXxxXXXXXXXxxxxXXXXXX',
  5. 'endpoint' => 'https://xxxxxxxxx.execute-api.ap-northeast-1.amazonaws.com/v0',
  6. 'timeout' => '30.0',
  7. 'notifications' => [
  8. [
  9. 'type'=> 'slack',
  10. 'endpoint'=> 'https://hooks.slack.com/services/XXXXXXXXXX/B2RAD9423/WC2uTs3MyGldZvieAtAA7gQq',
  11. 'channel'=> '#random',
  12. 'username'=> 'faultline-notify',
  13. 'notifyInterval'=> 5,
  14. 'threshold'=> 10,
  15. 'timezone'=> 'Asia/Tokyo'
  16. ],
  17. [
  18. 'type'=> 'github',
  19. 'userToken'=> 'XXXXXXXxxxxXXXXXXxxxxxXXXXXXXXXX',
  20. 'owner'=> 'k1LoW',
  21. 'repo'=> 'faultline',
  22. 'labels'=> [
  23. 'faultline', 'bug'
  24. ],
  25. 'if_exist'=> 'reopen-and-comment',
  26. 'notifyInterval'=> 1,
  27. 'threshold'=> 1,
  28. 'timezone'=> 'Asia/Tokyo'
  29. ]
  30. ]
  31. ]);
  32. // Set global notifier instance.
  33. Faultline\Instance::set($notifier);
  34. // Register error and exception handlers.
  35. $handler = new Faultline\ErrorHandler($notifier);
  36. $handler->register();
  37. // Somewhere in the app...
  38. try {
  39. throw new Exception('hello from faultline-php');
  40. } catch(Exception $e) {
  41. Faultline\Instance::notify($e);
  42. }

Monolog integration

  1. $log = new Monolog\Logger('acl');
  2. $log->pushHandler(new Faultline\MonologHandler($notifier));
  3. $log->addError('permission denied', ['user_id' => 123]);

References

License

MIT © Ken’ichiro Oyama