Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
This commit is contained in:
83
tests/debug/debug-manual-discovery.php
Normal file
83
tests/debug/debug-manual-discovery.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
use App\Framework\Console\ConsoleCommandMapper;
|
||||
use App\Framework\Core\ValueObjects\ClassName;
|
||||
use App\Framework\Discovery\ValueObjects\FileContext;
|
||||
use App\Framework\Discovery\Visitors\AttributeVisitor;
|
||||
use App\Framework\Filesystem\File;
|
||||
use App\Framework\Filesystem\FileMetadata;
|
||||
use App\Framework\Filesystem\FilePath;
|
||||
|
||||
echo "=== Manual Discovery Test ===" . PHP_EOL;
|
||||
|
||||
// Create the attribute visitor with console command mapper
|
||||
$visitor = new AttributeVisitor([
|
||||
new ConsoleCommandMapper(),
|
||||
]);
|
||||
|
||||
echo "✅ AttributeVisitor created with ConsoleCommandMapper" . PHP_EOL;
|
||||
|
||||
// Test with the MCP Server Command class
|
||||
$className = ClassName::create('App\\Framework\\Mcp\\Console\\McpServerCommand');
|
||||
$filePathStr = __DIR__ . '/../../src/Framework/Mcp/Console/McpServerCommand.php';
|
||||
$filePath = FilePath::create($filePathStr);
|
||||
|
||||
// Create file metadata
|
||||
$stat = stat($filePathStr);
|
||||
$metadata = new FileMetadata(
|
||||
path: $filePath,
|
||||
size: $stat['size'] ?? 0,
|
||||
lastModified: $stat['mtime'] ?? time()
|
||||
);
|
||||
|
||||
$file = new File($filePath, $metadata);
|
||||
$context = new FileContext($file, $filePath);
|
||||
|
||||
echo "Testing class: " . $className->getFullyQualified() . PHP_EOL;
|
||||
echo "File path: " . $filePath->toString() . PHP_EOL;
|
||||
|
||||
try {
|
||||
// Visit the class to discover attributes
|
||||
$visitor->visitClass($className, $context);
|
||||
|
||||
// Get the discovered attributes
|
||||
$registry = $visitor->getRegistry();
|
||||
$consoleCommands = $registry->get('App\\Framework\\Console\\ConsoleCommand');
|
||||
|
||||
echo "ConsoleCommand attributes found: " . count($consoleCommands) . PHP_EOL;
|
||||
|
||||
if (! empty($consoleCommands)) {
|
||||
foreach ($consoleCommands as $i => $command) {
|
||||
echo "Command $i:" . PHP_EOL;
|
||||
echo " Class: " . $command->className->getFullyQualified() . PHP_EOL;
|
||||
echo " Method: " . ($command->methodName?->toString() ?? 'unknown') . PHP_EOL;
|
||||
echo " Arguments: " . json_encode($command->arguments) . PHP_EOL;
|
||||
|
||||
$instance = $command->createAttributeInstance();
|
||||
if ($instance) {
|
||||
echo " Name: " . $instance->name . PHP_EOL;
|
||||
echo " Description: " . $instance->description . PHP_EOL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "❌ No ConsoleCommand attributes found!" . PHP_EOL;
|
||||
|
||||
// Check what attributes were found
|
||||
$allTypes = $registry->getAllTypes();
|
||||
echo "Available attribute types: " . count($allTypes) . PHP_EOL;
|
||||
foreach ($allTypes as $type) {
|
||||
$count = $registry->getCount($type);
|
||||
echo " - $type: $count" . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
echo "Total attributes discovered: " . $registry->count() . PHP_EOL;
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo "❌ Error during discovery: " . $e->getMessage() . PHP_EOL;
|
||||
echo "Stack trace: " . $e->getTraceAsString() . PHP_EOL;
|
||||
}
|
||||
Reference in New Issue
Block a user