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:
2025-08-11 20:13:26 +02:00
parent 59fd3dd3b1
commit 55a330b223
3683 changed files with 2956207 additions and 16948 deletions

View File

@@ -0,0 +1,124 @@
<?php
declare(strict_types=1);
namespace App\Framework\Discovery\Commands;
use App\Framework\Cache\Cache;
use App\Framework\Console\ConsoleCommand;
use App\Framework\Console\ConsoleInput;
use App\Framework\Console\ConsoleOutput;
use App\Framework\Core\PathProvider;
use App\Framework\DateTime\Clock;
use App\Framework\Discovery\DiscoveryCache;
/**
* Unified console commands for clearing discovery-related caches
*
* Consolidates functionality from both Discovery and Core cache clearing commands:
* - discovery:clear-cache: Clear only Discovery service cache
* - discovery:clear: Clear all discovery-related caches (Discovery + Routes + Legacy)
* - routes:clear: Clear only routes cache
*/
final readonly class ClearDiscoveryCache
{
public function __construct(
private Cache $cache,
private Clock $clock,
private ConsoleOutput $output,
private PathProvider $pathProvider
) {
}
#[ConsoleCommand(name: 'discovery:clear-cache', description: 'Clear Discovery cache')]
public function handle(): int
{
$this->output->writeLine('Clearing Discovery cache...');
try {
$discoveryCache = new DiscoveryCache($this->cache, $this->clock);
if ($discoveryCache->flush()) {
$this->output->writeLine('<success>Discovery cache cleared successfully!</success>');
return 0;
} else {
$this->output->writeLine('<error>Failed to clear Discovery cache - flush returned false</error>');
return 1;
}
} catch (\Throwable $e) {
$this->output->writeLine('<error>Failed to clear Discovery cache: ' . $e->getMessage() . '</error>');
return 1;
}
}
#[ConsoleCommand(name: 'discovery:clear', description: 'Clear all discovery-related caches')]
public function clearAll(): int
{
$this->output->writeLine('Clearing all discovery-related caches...');
$success = true;
// Clear discovery cache
$discoveryCache = new DiscoveryCache($this->cache, $this->clock);
if ($discoveryCache->flush()) {
$this->output->writeLine('✓ Discovery cache cleared');
} else {
$this->output->writeLine('✗ Failed to clear Discovery cache');
$success = false;
}
// Clear legacy cache keys from old Core command
$this->cache->forget('discovery_service');
$this->cache->forget('unified_discovery_results');
$this->output->writeLine('✓ Legacy discovery cache keys cleared');
// Clear routes cache
if ($this->clearRoutesCache()) {
$this->output->writeLine('✓ Routes cache cleared');
} else {
$this->output->writeLine('✗ Failed to clear routes cache');
$success = false;
}
if ($success) {
$this->output->writeLine('<success>All discovery caches cleared successfully!</success>');
return 0;
} else {
$this->output->writeLine('<error>Some caches could not be cleared</error>');
return 1;
}
}
#[ConsoleCommand(name: 'routes:clear', description: 'Clear routes cache')]
public function clearRoutes(ConsoleInput $input, ConsoleOutput $output): int
{
if ($this->clearRoutesCache()) {
$output->writeLine('<success>Routes cache cleared successfully!</success>');
return 0;
} else {
$output->writeLine('<error>Routes cache not found or could not be cleared</error>');
return 1;
}
}
/**
* Clear routes cache file
*/
private function clearRoutesCache(): bool
{
$routesCachePath = $this->pathProvider->resolvePath('/cache/routes.cache.php');
if (! file_exists($routesCachePath)) {
return true; // Consider it success if file doesn't exist
}
return unlink($routesCachePath);
}
}