@@ -15,6 +15,10 @@ An extensive Laravel plugin system that provides automatic registration of route
1515- ** Performance Tracking** - Monitor memory usage, execution time, error rates, and database queries
1616- ** Alert System** - Multi-channel alerts (log, email, Slack) for plugin issues
1717- ** Health Commands** - Artisan commands for health checks and error management
18+ - 🔧 ** Debug & Profiling Tools** - Comprehensive debugging tools for plugin development
19+ - 📊 ** Performance Analysis** - Advanced profiling with bottleneck detection and recommendations
20+ - 📋 ** Log Management** - Plugin-specific log filtering, tailing, and analysis
21+ - 🔍 ** Request Debugging** - Middleware for request/response debugging and performance tracking
1822
1923## Installation
2024
@@ -329,6 +333,137 @@ Clear errors for specific plugin:
329333php artisan plugin:health MyAwesomePlugin --clear-errors
330334```
331335
336+ ## Plugin Debugging & Profiling Tools
337+
338+ The plugin system includes comprehensive debugging and profiling tools to help developers analyze plugin performance, troubleshoot issues, and optimize their code.
339+
340+ ### Debug Commands
341+
342+ #### Plugin Debug Command
343+
344+ Monitor plugin execution with detailed debugging information:
345+
346+ ``` bash
347+ # Debug all plugins
348+ php artisan plugin:debug
349+
350+ # Debug specific plugin
351+ php artisan plugin:debug MyAwesomePlugin
352+
353+ # Enable trace mode for detailed execution flow
354+ php artisan plugin:debug --trace
355+
356+ # Monitor memory usage
357+ php artisan plugin:debug --memory
358+
359+ # Track database queries
360+ php artisan plugin:debug --queries
361+
362+ # Monitor slow queries (over 100ms)
363+ php artisan plugin:debug --slow-queries
364+
365+ # Watch mode for continuous monitoring
366+ php artisan plugin:debug --watch
367+
368+ # Output in JSON format
369+ php artisan plugin:debug --format=json
370+
371+ # Detailed output with all information
372+ php artisan plugin:debug --format=detailed
373+ ```
374+
375+ #### Plugin Log Viewer
376+
377+ View and manage plugin-specific logs:
378+
379+ ``` bash
380+ # View logs for specific plugin
381+ php artisan plugin:logs MyAwesomePlugin
382+
383+ # Filter by log level
384+ php artisan plugin:logs MyAwesomePlugin --level=error
385+
386+ # Tail logs in real-time
387+ php artisan plugin:logs MyAwesomePlugin --tail
388+
389+ # Limit number of lines
390+ php artisan plugin:logs MyAwesomePlugin --lines=50
391+
392+ # Filter by date
393+ php artisan plugin:logs MyAwesomePlugin --since=" 2024-01-01"
394+
395+ # Search for specific text
396+ php artisan plugin:logs MyAwesomePlugin --search=" database error"
397+
398+ # Export logs to file
399+ php artisan plugin:logs MyAwesomePlugin --export=logs.txt
400+
401+ # Clear plugin logs
402+ php artisan plugin:logs MyAwesomePlugin --clear
403+
404+ # Output in different formats
405+ php artisan plugin:logs MyAwesomePlugin --format=json
406+ ```
407+
408+ ### Profiling Features
409+
410+ #### Performance Analysis
411+
412+ The profiling service provides detailed performance analysis:
413+
414+ - ** Execution Time Tracking** - Monitor method execution times
415+ - ** Memory Usage Analysis** - Track memory consumption patterns
416+ - ** Database Query Profiling** - Analyze query performance and N+1 issues
417+ - ** Bottleneck Detection** - Identify performance bottlenecks automatically
418+ - ** Performance Recommendations** - Get actionable optimization suggestions
419+ - ** Plugin Comparison** - Compare performance across different plugins
420+ - ** Anomaly Detection** - Detect unusual performance patterns
421+
422+ #### Debug Middleware
423+
424+ Enable request-level debugging by adding the middleware to your routes:
425+
426+ ``` php
427+ Route::middleware(['plugin.debug'])->group(function () {
428+ // Your plugin routes
429+ });
430+ ```
431+
432+ The middleware provides:
433+
434+ - ** Request/Response Logging** - Complete request and response data
435+ - ** Performance Metrics** - Execution time and memory usage per request
436+ - ** Query Tracking** - Database queries executed during request
437+ - ** Debug Headers** - Performance data in response headers
438+ - ** Error Tracking** - Automatic error logging and analysis
439+
440+ ### Debugging Configuration
441+
442+ Configure debugging tools in ` config/laravel-plugin-system.php ` :
443+
444+ ``` php
445+ 'debugging' => [
446+ 'enabled' => true,
447+ 'profiling' => [
448+ 'enabled' => true,
449+ 'memory_tracking' => true,
450+ 'query_tracking' => true,
451+ 'slow_query_threshold' => 100, // milliseconds
452+ ],
453+ 'logging' => [
454+ 'enabled' => true,
455+ 'log_requests' => true,
456+ 'log_responses' => true,
457+ 'sanitize_sensitive_data' => true,
458+ ],
459+ 'cache' => [
460+ 'enabled' => true,
461+ 'ttl' => 3600, // 1 hour
462+ 'max_entries' => 1000,
463+ ],
464+ ],
465+ ```
466+
332467### Health Monitoring Features
333468
334469#### Automatic Metrics Collection
0 commit comments