irap/exception-logger
最新稳定版本:1.2.0
Composer 安装命令:
composer require irap/exception-logger
包简介
Package for capturing and logging uncaught exceptions.
关键字:
README 文档
README
A package to capture uncaught exceptions and log them using the provided logger. All you have to do is create the object like so:
new \iRAP\ExceptionLogger\ExceptionLogger( $logger, // objec tof LoggerInterface "My Service", $nextExcptionHandler=function(Throwable $e) { /* do nothing */ } );
This will result in any uncaught exceptions being logged. The object works by setting the exception handler so it won't have any effect if you call set_exception_handler after having created the object.
If you want to run your own exception handler, you can just have it be called by the callback as shown below:
/* @var $logger LoggerInterface */ $nextExcptionHandler = function(Throwable $e) { // my custom uncaught exception handling goes here. }; new \iRAP\ExceptionLogger\ExceptionLogger( $logger, "My Service", nextExcptionHandler );
If you don't have a custom exception handler, I would recommend restoring PHP's default exception handling by doing the following:
$next = function(Throwable $e) { restore_exception_handler(); throw $e; //This triggers the previous exception handler }; new \iRAP\ExceptionLogger\ExceptionLogger( $logger, "My Service", $next );
统计信息
- 总下载量: 1.41k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-08-21