Skip to content

[TASK] Improve Warnings #891

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

use function assert;
use function get_debug_type;
use function sprintf;

final class ConfigurationBlockDirective extends SubDirective
{
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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"} []