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

@@ -4,44 +4,68 @@ declare(strict_types=1);
namespace App\Framework\Cache;
use App\Framework\Core\ValueObjects\Duration;
final readonly class LoggingCacheDecorator implements Cache
{
public function __construct(
private Cache $innerCache,
) {}
public function get(string $key): CacheItem
{
$cacheItem = $this->innerCache->get($key);
$status = $cacheItem->isHit ? 'HIT' : 'MISS';
$valueType = $cacheItem->value === null ? 'NULL' : gettype($cacheItem->value);
error_log("Cache {$status}: {$key} (value: {$valueType})");
return $cacheItem;
) {
}
public function set(string $key, mixed $value, ?int $ttl = null): bool
public function get(CacheIdentifier ...$identifiers): CacheResult
{
$result = $this->innerCache->set($key, $value, $ttl);
$valueType = $value === null ? 'NULL' : gettype($value);
$ttlStr = $ttl === null ? 'default' : (string)$ttl;
$success = $result ? 'YES' : 'NO';
error_log("Cache SET: {$key} = {$valueType}, TTL: {$ttlStr}, Success: {$success}");
$result = $this->innerCache->get(...$identifiers);
$hitCount = $result->getHits()->count();
$missCount = $result->getMisses()->count();
$identifierList = implode(', ', array_map(fn ($id) => $id->toString(), $identifiers));
error_log("Cache GET: [{$identifierList}] - Hits: {$hitCount}, Misses: {$missCount}");
return $result;
}
public function has(string $key): bool
public function set(CacheItem ...$items): bool
{
$exists = $this->innerCache->has($key);
$existsStr = $exists ? 'YES' : 'NO';
error_log("Cache HAS: {$key} = {$existsStr}");
return $exists;
$result = $this->innerCache->set(...$items);
$count = count($items);
$success = $result ? 'YES' : 'NO';
foreach ($items as $item) {
$valueType = $item->value === null ? 'NULL' : gettype($item->value);
$ttlStr = $item->ttl === null ? 'default' : $item->ttl->toSeconds() . 's';
error_log("Cache SET: {$item->key} = {$valueType}, TTL: {$ttlStr}");
}
error_log("Cache SET_BATCH: {$count} items, Success: {$success}");
return $result;
}
public function forget(string $key): bool
public function has(CacheIdentifier ...$identifiers): array
{
$result = $this->innerCache->forget($key);
$result = $this->innerCache->has(...$identifiers);
foreach ($result as $identifierString => $exists) {
$existsStr = $exists ? 'YES' : 'NO';
error_log("Cache HAS: {$identifierString} = {$existsStr}");
}
return $result;
}
public function forget(CacheIdentifier ...$identifiers): bool
{
$result = $this->innerCache->forget(...$identifiers);
$count = count($identifiers);
$success = $result ? 'YES' : 'NO';
error_log("Cache FORGET: {$key}, Success: {$success}");
$identifierList = implode(', ', array_map(fn ($id) => $id->toString(), $identifiers));
error_log("Cache FORGET: [{$identifierList}], Success: {$success}");
return $result;
}
@@ -50,54 +74,18 @@ final readonly class LoggingCacheDecorator implements Cache
$result = $this->innerCache->clear();
$success = $result ? 'YES' : 'NO';
error_log("Cache CLEAR: Success: {$success}");
return $result;
}
public function getMultiple(array $keys): array
{
$items = $this->innerCache->getMultiple($keys);
$hitCount = 0;
$missCount = 0;
foreach ($items as $item) {
if ($item->isHit) {
$hitCount++;
} else {
$missCount++;
}
}
$keyList = implode(', ', $keys);
error_log("Cache GET_MULTIPLE: [{$keyList}] - Hits: {$hitCount}, Misses: {$missCount}");
return $items;
}
public function setMultiple(array $items, ?int $ttl = null): bool
{
$result = $this->innerCache->setMultiple($items, $ttl);
$count = count($items);
$ttlStr = $ttl === null ? 'default' : (string)$ttl;
$success = $result ? 'YES' : 'NO';
error_log("Cache SET_MULTIPLE: {$count} items, TTL: {$ttlStr}, Success: {$success}");
return $result;
}
public function deleteMultiple(array $keys): bool
{
$result = $this->innerCache->deleteMultiple($keys);
$count = count($keys);
$success = $result ? 'YES' : 'NO';
error_log("Cache DELETE_MULTIPLE: {$count} keys, Success: {$success}");
return $result;
}
public function remember(string $key, callable $callback, int $ttl = 3600): CacheItem
public function remember(CacheKey $key, callable $callback, ?Duration $ttl = null): CacheItem
{
$result = $this->innerCache->remember($key, $callback, $ttl);
$success = $result->isHit ? 'YES' : 'NO';
error_log("Cache REMEMBER: {$key}, Success: {$success}");
$status = $result->isHit ? 'HIT' : 'COMPUTED';
$ttlStr = $ttl === null ? 'default' : $ttl->toSeconds() . 's';
error_log("Cache REMEMBER: {$key} = {$status}, TTL: {$ttlStr}");
return $result;
}
}