stafred / detector

错误检测和启动服务

dev-master 2023-09-18 14:59 UTC

This package is auto-updated.

Last update: 2024-09-18 17:01:59 UTC


README

composer require stafred/detector

关于Detector

该软件包用于使用一组小设置检测错误和异常。检测器轻量级,允许你在处理器中运行任何代码。指定运行设置:错误日志文件夹的路径、错误日志文件名、显示错误简要信息的权限、启动调试器的权限或子例程的一部分。

方法

->setErrorDebug(...) 
->setErrorInfo(...) 
->setErrorNameLog(...) 
->setErrorPathLog(...) 
->make(...) 

示例

$detector = new \Detector\Run;
$detector->setErrorDebug(your_constant_or_value);
$detector->setErrorInfo(your_constant_or_value);
$detector->setErrorNameLog(your_constant_or_value);
$detector->setErrorPathLog(your_constant_or_value);
$detector->make(function(){
     your_handler_or_code
});

带有Package Filp\Whoops的示例

$detector = new \Detector\Run;
$detector->setErrorDebug('APP_DEBUG');
$detector->setErrorInfo('ERROR_INFO');
$detector->setErrorNameLog('ERROR_NAME_LOG');
$detector->setErrorPathLog('ERROR_PATH_LOG');
$detector->make(function(){
     $whoops = new \Whoops\Run;
     $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
     $whoops->register();
});

计时

APP_DEBUG = false : max response 0.009 sec
APP_DEBUG = true  : max response 0.014 sec (+55%)