tina4stack / tina4php-debug
Tina4 PHP 调试功能
v2.0.13
2024-07-13 14:23 UTC
Requires
- cesargb/php-log-rotation: ^2.7
- psr/log: ^1.1
- twig/twig: ^3.3
Requires (Dev)
- overtrue/phplint: ^2.0
- phpunit/phpunit: ^9
- roave/security-advisories: dev-latest
README
Tina4 Php Debug
一个通用的调试模块,可以增强您的普通 PHP 项目
使用 composer 安装模块
composer require tina4stack/tina4php-debug
一些预期示例
正常的错误处理如下
Tina4 调试异常处理和错误将自动显示在屏幕上。
您还将获得一些漂亮的控制台输出
在您的项目中设置此功能
在您的代码中,您需要设置一些常量以使此功能正常工作。
<?php const TINA4_DOCUMENT_ROOT = __DIR__; const TINA4_DEBUG = true; require_once "vendor/autoload.php"; //Set the log level of what you want reported to console //Can be an array of the values as listed below \Tina4\Debug::$logLevel = [TINA4_LOG_DEBUG, TINA4_LOG_INFO]; //You can code here as per normal //If you want to output console messages use code like this \Tina4\Debug::message("Testing", TINA4_LOG_DEBUG); \Tina4\Debug::message("Testing", TINA4_LOG_WARNING); \Tina4\Debug::message("Testing", TINA4_LOG_ERROR); \Tina4\Debug::message("Testing", TINA4_LOG_INFO); \Tina4\Debug::message("Testing", TINA4_LOG_CRITICAL); //Render the debug echo \Tina4\DebugRender::render();
日志级别
const TINA4_LOG_EMERGENCY = "emergency";
const TINA4_LOG_ALERT = "alert";
const TINA4_LOG_CRITICAL = "critical";
const TINA4_LOG_ERROR = "error";
const TINA4_LOG_WARNING = "warning";
const TINA4_LOG_NOTICE = "notice";
const TINA4_LOG_INFO = "info";
const TINA4_LOG_DEBUG = "debug";
const TINA4_LOG_ALL = "all";