diff --git a/packages/guides-restructured-text/src/RestructuredText/Directives/ConfigurationBlockDirective.php b/packages/guides-restructured-text/src/RestructuredText/Directives/ConfigurationBlockDirective.php index c4cf42adc..8c316a3c0 100644 --- a/packages/guides-restructured-text/src/RestructuredText/Directives/ConfigurationBlockDirective.php +++ b/packages/guides-restructured-text/src/RestructuredText/Directives/ConfigurationBlockDirective.php @@ -27,6 +27,7 @@ use function assert; use function get_debug_type; +use function sprintf; final class ConfigurationBlockDirective extends SubDirective { @@ -59,7 +60,10 @@ protected function processSub( $tabs = []; foreach ($collectionNode->getValue() as $child) { if (!$child instanceof CodeNode) { - $this->logger->warning('The ".. configuration-block::" directive only supports code blocks, "' . get_debug_type($child) . '" given.'); + $this->logger->warning( + sprintf('The ".. configuration-block::" directive only supports code blocks, "%s" given.', get_debug_type($child)), + $blockContext->getLoggerInformation(), + ); continue; } diff --git a/packages/guides-restructured-text/src/RestructuredText/Directives/CsvTableDirective.php b/packages/guides-restructured-text/src/RestructuredText/Directives/CsvTableDirective.php index 7dc451439..f747d1a96 100644 --- a/packages/guides-restructured-text/src/RestructuredText/Directives/CsvTableDirective.php +++ b/packages/guides-restructured-text/src/RestructuredText/Directives/CsvTableDirective.php @@ -27,6 +27,7 @@ use function array_filter; use function array_map; +use function array_merge; use function assert; use function count; use function explode; @@ -69,7 +70,10 @@ public function processNode( ->readStream((string) $directive->getOption('file')->getValue()); if ($csvStream === false) { - $this->logger->error('Unable to read CSV file {file}', ['file' => $directive->getOption('file')->getValue()]); + $this->logger->error( + 'Unable to read CSV file {file}', + array_merge(['file' => $directive->getOption('file')->getValue()], $blockContext->getLoggerInformation()), + ); return new GenericNode('csv-table'); } diff --git a/packages/guides-restructured-text/src/RestructuredText/Directives/TableDirective.php b/packages/guides-restructured-text/src/RestructuredText/Directives/TableDirective.php index 2e2b320fc..93b731b3c 100644 --- a/packages/guides-restructured-text/src/RestructuredText/Directives/TableDirective.php +++ b/packages/guides-restructured-text/src/RestructuredText/Directives/TableDirective.php @@ -64,14 +64,20 @@ protected function processSub( Directive $directive, ): Node|null { if (count($collectionNode->getChildren()) !== 1) { - $this->logger->warning(sprintf('The table directive may contain exactly one table. %s children found', count($collectionNode->getChildren()))); + $this->logger->warning( + sprintf('The table directive may contain exactly one table. %s children found', count($collectionNode->getChildren())), + $blockContext->getLoggerInformation(), + ); return $collectionNode; } $tableNode = $collectionNode->getChildren()[0]; if (!$tableNode instanceof TableNode) { - $this->logger->warning(sprintf('The table directive may contain exactly one table. A node of type %s was found. ', $tableNode::class)); + $this->logger->warning( + sprintf('The table directive may contain exactly one table. A node of type %s was found. ', $tableNode::class), + $blockContext->getLoggerInformation(), + ); return $collectionNode; } diff --git a/packages/guides-restructured-text/src/RestructuredText/NodeRenderers/Html/GeneralDirectiveNodeRenderer.php b/packages/guides-restructured-text/src/RestructuredText/NodeRenderers/Html/GeneralDirectiveNodeRenderer.php index 8ea1caef9..4c1ad5a69 100644 --- a/packages/guides-restructured-text/src/RestructuredText/NodeRenderers/Html/GeneralDirectiveNodeRenderer.php +++ b/packages/guides-restructured-text/src/RestructuredText/NodeRenderers/Html/GeneralDirectiveNodeRenderer.php @@ -56,7 +56,7 @@ public function render(Node $node, RenderContext $renderContext): string 'No template found for rendering directive "%s". Expected template "%s"', $node->getName(), $template, - )); + ), $renderContext->getLoggerInformation()); $template = 'body/directive/not-found.html.twig'; return $this->renderer->renderTemplate($renderContext, $template, $data); diff --git a/packages/guides-restructured-text/src/RestructuredText/NodeRenderers/LaTeX/GeneralDirectiveNodeRenderer.php b/packages/guides-restructured-text/src/RestructuredText/NodeRenderers/LaTeX/GeneralDirectiveNodeRenderer.php index 94d371a29..a8706df08 100644 --- a/packages/guides-restructured-text/src/RestructuredText/NodeRenderers/LaTeX/GeneralDirectiveNodeRenderer.php +++ b/packages/guides-restructured-text/src/RestructuredText/NodeRenderers/LaTeX/GeneralDirectiveNodeRenderer.php @@ -56,7 +56,7 @@ public function render(Node $node, RenderContext $renderContext): string 'No template found for rendering directive "%s". Expected template "%s"', $node->getName(), $template, - )); + ), $renderContext->getLoggerInformation()); $template = 'body/directive/not-found.html.twig'; return $this->renderer->renderTemplate($renderContext, $template, $data); diff --git a/packages/guides-theme-bootstrap/src/Bootstrap/Directives/TabsDirective.php b/packages/guides-theme-bootstrap/src/Bootstrap/Directives/TabsDirective.php index 5cff70f3d..d572fe938 100644 --- a/packages/guides-theme-bootstrap/src/Bootstrap/Directives/TabsDirective.php +++ b/packages/guides-theme-bootstrap/src/Bootstrap/Directives/TabsDirective.php @@ -69,7 +69,10 @@ protected function processSub( $tabs[] = $child; } else { - $this->logger->warning('The "tabs" directive may only contain children of type "tab". The following node was found: ' . $child::class); + $this->logger->warning( + 'The "tabs" directive may only contain children of type "tab". The following node was found: ' . $child::class, + $blockContext->getLoggerInformation(), + ); } } diff --git a/tests/Integration/tests/directives/directive-unkown/expected/logs/warning.log b/tests/Integration/tests/directives/directive-unkown/expected/logs/warning.log index 0b8cabb28..c4e06dafd 100644 --- a/tests/Integration/tests/directives/directive-unkown/expected/logs/warning.log +++ b/tests/Integration/tests/directives/directive-unkown/expected/logs/warning.log @@ -1 +1 @@ -app.WARNING: No template found for rendering directive "some-unknown-directive". Expected template "body/directive/some-unknown-directive.html.twig" [] [] +app.WARNING: No template found for rendering directive "some-unknown-directive". Expected template "body/directive/some-unknown-directive.html.twig" {"rst-file":"index"} []