From 4bbcd1af6a9f6e5a85d7ade3f192c52c1ecb4947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bedn=C3=A1=C5=99?= Date: Wed, 16 Apr 2025 08:21:51 +0200 Subject: [PATCH] Tracy: add option to set max depth of dumped contents --- src/DI/EventDispatcherExtension.php | 9 ++++++++- src/Tracy/EventPanel.php | 5 ++++- src/Tracy/templates/panel.phtml | 11 ++++++----- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/DI/EventDispatcherExtension.php b/src/DI/EventDispatcherExtension.php index ed80267..56535b5 100644 --- a/src/DI/EventDispatcherExtension.php +++ b/src/DI/EventDispatcherExtension.php @@ -32,6 +32,7 @@ public function getConfigSchema(): Schema 'lazy' => Expect::bool(true), 'autoload' => Expect::bool(true), 'debug' => Expect::bool(false), + 'debugContentDepth' => Expect::int(2), 'loggers' => Expect::arrayOf(Expect::type(Statement::class)), ]); } @@ -92,7 +93,13 @@ public function afterCompile(ClassType $class): void // @phpstan-ignore-next-line $builder->formatPhp('?->addPanel(?);', [ $builder->getDefinitionByType(Bar::class), - new Statement(EventPanel::class, [$builder->getDefinition($this->prefix('dispatcher.tracy'))]), + new Statement( + EventPanel::class, + [ + $builder->getDefinition($this->prefix('dispatcher.tracy')), + $config->debugContentDepth, + ] + ), ]) ); } diff --git a/src/Tracy/EventPanel.php b/src/Tracy/EventPanel.php index 91d4c0f..b01232a 100644 --- a/src/Tracy/EventPanel.php +++ b/src/Tracy/EventPanel.php @@ -9,10 +9,12 @@ class EventPanel implements IBarPanel { private TracyDispatcher $dispatcher; + private int $debugContentDepth; - public function __construct(TracyDispatcher $dispatcher) + public function __construct(TracyDispatcher $dispatcher, int $debugContentDepth) { $this->dispatcher = $dispatcher; + $this->debugContentDepth = $debugContentDepth; } /** @@ -40,6 +42,7 @@ public function getPanel(): string $totalTime = $this->countTotalTime(); // @phpcs:ignore $events = $this->dispatcher->getEvents(); // @phpcs:ignore $listeners = $this->dispatcher->getListeners(); + $debugContentDepth = $this->debugContentDepth; ksort($listeners); ob_start(); require __DIR__ . '/templates/panel.phtml'; diff --git a/src/Tracy/templates/panel.phtml b/src/Tracy/templates/panel.phtml index a278e82..47d2b8e 100644 --- a/src/Tracy/templates/panel.phtml +++ b/src/Tracy/templates/panel.phtml @@ -1,11 +1,12 @@ $listeners */ /** @var int $handledCount */ /** @var float $totalTime */ -use Contributte\EventDispatcher\Diagnostics\EventInfo; +use Contributte\EventDispatcher\Diagnostics\EventTrace; use Tracy\Dumper; ?>