Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[WebProfilerBundle] add extra data to logs panel #54445

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

Open
wants to merge 1 commit into
base: 7.3
Choose a base branch
Loading
from
Open
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
1 change: 1 addition & 0 deletions 1 src/Symfony/Bridge/Monolog/Processor/DebugProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function __invoke(LogRecord $record): LogRecord
'priority' => $record->level->value,
'priorityName' => $record->level->getName(),
'context' => $record->context,
'extra' => $record->extra,
'channel' => $record->channel ?? '',
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@
{% macro render_log_message(category, log_index, log) %}
{% set has_context = log.context is defined and log.context is not empty %}
{% set has_trace = log.context.exception.trace is defined %}
{% set has_extra = log.extra is defined and log.extra is not empty %}

{% if not has_context %}
{{ profiler_dump_log(log.message) }}
Expand All @@ -566,6 +567,11 @@
<span><button type="button" class="btn btn-link text-small sf-toggle" data-toggle-selector="#{{ trace_id }}" data-toggle-alt-content="Hide trace">Show trace</button></span>
{% endif %}

{% if has_extra %}
{% set extra_id = 'extra-data-' ~ category ~ '-' ~ log_index %}
<span><button type="button" class="btn btn-link text-small sf-toggle" data-toggle-selector="#{{ extra_id }}" data-toggle-alt-content="Hide extra data">Show extra data</button></span>
{% endif %}

{% if has_context %}
<div id="{{ context_id }}" class="context sf-toggle-content sf-toggle-hidden">
{{ profiler_dump(log.context, maxDepth=1) }}
Expand All @@ -577,5 +583,11 @@
{{ profiler_dump(log.context.exception.trace, maxDepth=1) }}
</div>
{% endif %}

{% if has_extra %}
<div id="{{ extra_id }}" class="context sf-toggle-content sf-toggle-hidden">
{{ profiler_dump(log.extra, maxDepth=1) }}
</div>
{% endif %}
</div>
{% endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public function getProcessedLogs(): array
'channel' => $rawLogData['channel']->getValue(),
'message' => $rawLogData['message'],
'context' => $rawLogData['context'],
'extra' => $rawLogData['extra'],
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ public function __construct(callable $processor, ?bool $enable = null)
public function pushDebugLogger(Logger $logger): void
{
if ($this->processor) {
$processors = $logger->getProcessors();
while ([] !== $logger->getProcessors()) {
$logger->popProcessor();
}
Comment on lines +33 to +36
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really not sure about this. Adding tag priority like suggested here symfony/monolog-bundle#455 might help


// Ensure the DebugLogger is the first processor as Monolog add processors in reverse order
$logger->pushProcessor($this->processor);
foreach ($processors as $processor) {
$logger->pushProcessor($processor);
}
Comment on lines +38 to +42
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me this would deserve its own PR.. as this one only says "add extra data" and not "changes the order of procesors" :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, that's why I'm not 100% sure about this change. But if processors are left as is, DebugProcessor is the very last to be pushed to the list, and it will not get extra data added by next processors (because of reverse order used by Monolog).

Do you see another way to do so ? Working on CompilerPass looks pretty complex.

}
}

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.