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:
@@ -1,47 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\CommandBus;
|
||||
|
||||
use App\Application\Auth\LoginUser;
|
||||
use App\Framework\CommandBus\Exceptions\NoHandlerFound;
|
||||
use App\Framework\CommandBus\Middleware\DatabaseTransactionMiddleware;
|
||||
use App\Framework\CommandBus\Middleware\PerformanceMonitoringMiddleware;
|
||||
use App\Framework\Context\ExecutionContext;
|
||||
use App\Framework\Context\ContextType;
|
||||
use App\Framework\Context\ExecutionContext;
|
||||
use App\Framework\DI\Container;
|
||||
use App\Framework\DI\DefaultContainer;
|
||||
use App\Framework\Queue\FileQueue;
|
||||
use App\Framework\Logging\Logger;
|
||||
use App\Framework\Queue\Queue;
|
||||
use App\Framework\Queue\RedisQueue;
|
||||
|
||||
final readonly class DefaultCommandBus implements CommandBus
|
||||
final class DefaultCommandBus implements CommandBus
|
||||
{
|
||||
public function __construct(
|
||||
private CommandHandlersCollection $commandHandlers,
|
||||
private Container $container,
|
||||
private ExecutionContext $executionContext,
|
||||
private Queue $queue = new RedisQueue(host: 'redis'),
|
||||
private Queue $queue,
|
||||
private Logger $logger,
|
||||
private array $middlewares = [
|
||||
PerformanceMonitoringMiddleware::class,
|
||||
DatabaseTransactionMiddleware::class,
|
||||
],
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
public function dispatch(object $command): mixed
|
||||
{
|
||||
$contextType = $this->executionContext->getType();
|
||||
error_log("CommandBus Debug: Execution context: {$contextType->value}");
|
||||
error_log("CommandBus Debug: Context metadata: " . json_encode($this->executionContext->getMetadata()));
|
||||
// Debug logging removed for production - only log errors
|
||||
|
||||
// Context-basierte Queue-Entscheidung
|
||||
if ($this->shouldQueueInContext($command, $contextType)) {
|
||||
error_log("CommandBus Debug: Job wird in Queue eingereiht: " . $command::class);
|
||||
// No logging for normal queue operations in production
|
||||
$this->queue->push($command);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
error_log("CommandBus Debug: Job wird direkt ausgeführt: " . $command::class);
|
||||
// No logging for normal direct execution in production
|
||||
|
||||
return $this->executeCommand($command);
|
||||
}
|
||||
|
||||
@@ -50,13 +51,13 @@ final readonly class DefaultCommandBus implements CommandBus
|
||||
$handlerExecutor = function (object $command): mixed {
|
||||
$handler = $this->commandHandlers->get($command::class);
|
||||
|
||||
if($handler === null)
|
||||
{
|
||||
throw NoHandlerFound::forCommand($command::class);
|
||||
if ($handler === null) {
|
||||
throw NoHandlerFound::forCommand($command::class);
|
||||
}
|
||||
|
||||
// $handler = $this->commandHandlers[get_class($command)];
|
||||
$handlerClass = $this->container->get($handler->class);
|
||||
|
||||
return $handlerClass->{$handler->method}($command);
|
||||
};
|
||||
|
||||
@@ -66,6 +67,7 @@ final readonly class DefaultCommandBus implements CommandBus
|
||||
return function (object $command) use ($middlewareClass, $next): mixed {
|
||||
/** @var Middleware $middleware */
|
||||
$middleware = $this->container->get($middlewareClass);
|
||||
|
||||
return $middleware->handle($command, $next);
|
||||
};
|
||||
},
|
||||
@@ -78,9 +80,9 @@ final readonly class DefaultCommandBus implements CommandBus
|
||||
private function shouldQueueInContext(object $command, ContextType $context): bool
|
||||
{
|
||||
$ref = new \ReflectionClass($command);
|
||||
$hasQueueAttribute = !empty($ref->getAttributes(ShouldQueue::class));
|
||||
$hasQueueAttribute = ! empty($ref->getAttributes(ShouldQueue::class));
|
||||
|
||||
if (!$hasQueueAttribute) {
|
||||
if (! $hasQueueAttribute) {
|
||||
return false; // Ohne #[ShouldQueue] Attribut nie queuen
|
||||
}
|
||||
|
||||
@@ -94,8 +96,6 @@ final readonly class DefaultCommandBus implements CommandBus
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function __debugInfo(): ?array
|
||||
{
|
||||
return $this->commandHandlers->toArray();
|
||||
|
||||
Reference in New Issue
Block a user