chabiselx/debuggertools
最新稳定版本:0.4.3
Composer 安装命令:
composer require chabiselx/debuggertools
包简介
Create a log for understand algorithm
README 文档
README
Description
DebuggerTools is a toolkit for developers, designed to facilitate debugging of PHP applications. It offers a set of classes to capture and analyze various aspects of your code execution, including:
- Logger: To log messages, errors, and various information.
- Time Monitor: To measure and log the execution time of code segments.
- Memory Monitor: To measure memory consumption of code segments.
- Trace: To trace function calls and follow code execution with fine granularity.
Table of Contents
Installation
Install DebuggerTools using Composer:
composer require --dev chabiselx/debuggerTools
Or clone the repository directly:
git clone https://github.com/chaBiselx/DebuggerTools.git
cd DebuggerTools
composer install
Run Docker for Development
Create the .env.local file at the project root.
Edit the ports in .env.local.env according to other Docker images:
- PHP_EXT_PORT_1
- PHP_EXT_PORT_2
- BDD_EXT_PORT
Run Docker for the first time:
make docker-build
To debug the build if needed:
docker-compose build --no-cache 2>&1 | tee build_logs.txt
Access the PHP container:
docker exec -it debuggertools-php7_3-1 bash
Testing
Outside a container:
make docker-test
Inside a container:
To run all tests:
make test
To run a specific test:
make test FILTER=file::function
Usage
ArrayOfOption
The ArrayOfOption parameter is an optional list. The possible fields are:
All:
hidePrefix[boolean]: Hide the date at the beginning of the string (default: false)showPrefix[boolean]: Show the date at the beginning of the string (default: true)purgeFileBefore[boolean]: Purge the file before writing (default: false)expendObject[boolean]: Expand for better visibility of arrays in the log file (default: false)fileName[string]: Write to the file with the given name (default: log)
For the MemoryMonitor class:
activeConvertion[boolean]: Enable unit-to-byte conversion (default: true)disactiveConvertion[boolean]: Disable unit-to-byte conversion (default: false)
Logger
To capture logs in your application:
use DebuggerTools\Logger; $logger = new Logger($ArrayOfOption); $logger->logger($dataToLog);
Via singleton:
\Debuggertools\Logger::loggerStatic($dataToLog, $ArrayOfOption);
Time Monitor
To measure the execution time of a code section:
use DebuggerTools\TimeMonitor; $time = new TimeMonitor($ArrayOfOption); $time->set("label"); sleep(5); $time->log("label");
Memory Monitor
To monitor the memory used by your application:
use DebuggerTools\MemoryMonitor; $memoryMonitor = new MemoryMonitor($ArrayOfOption); $memoryMonitor->logMemoryUsage('label'); //function $memoryMonitor->logMemoryUsage('label');
Trace
To trace code execution:
use DebuggerTools\Trace; $trace = new Trace($ArrayOfOption); $trace->logTrace();
Via singleton:
\Debuggertools\Trace::getTraceStatic($ArrayOfOption);
Contribute
Contributions are welcome! If you want to contribute:
- Fork the repository.
- Create a branch for your changes (
git checkout -b feature/new-feature). - Commit your changes (
git commit -m 'Add a new feature'). - Push the branch (
git push origin feature/new-feature). - Open a Pull Request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
TODO
- Improve the README
- Test Doctrine\ORM\PersistentCollection
- Middleware for all input/output
- EventListener for Symfony
- Fix SonarLint error (pathLog: getRootPath)
统计信息
- 总下载量: 107
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2024-03-18