-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[WebProfilerBundle] Display trace and context in the logger profiler #23588
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
Conversation
@lyrixx thanks for this feature. I like it a lot. However, I don't like the way links are displayed, each one in its own line: I prefer to put those links in a single line, like the database panel: I've made some changes in the Twig macro to display them like this: And this is with both links expanded: If you like this too, this is the full Twig macro code: {% 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 %}
{% if not has_context and not has_trace %}
{{ profiler_dump_log(log.message) }}
{% else %}
{{ profiler_dump_log(log.message, log.context) }}
<div class="text-small font-normal">
{% if has_context %}
{% set context_id = 'context-' ~ category ~ '-' ~ log_index %}
<a class="btn btn-link text-small sf-toggle" data-toggle-selector="#{{ context_id }}" data-toggle-alt-content="Hide context">Show context</a>
{% endif %}
{% if has_trace %}
{% set trace_id = 'trace-' ~ category ~ '-' ~ log_index %}
<a class="btn btn-link text-small sf-toggle" data-toggle-selector="#{{ trace_id }}" data-toggle-alt-content="Hide trace">Show trace</a>
{% endif %}
</div>
{% if has_context %}
<div id="{{ context_id }}" class="context sf-toggle-content sf-toggle-hidden">
{{ profiler_dump(log.context, maxDepth=1) }}
</div>
{% endif %}
{% if has_trace %}
<div id="{{ trace_id }}" class="context sf-toggle-content sf-toggle-hidden">
{{ profiler_dump(log.context.exception.trace, maxDepth=1) }}
</div>
{% endif %}
{% endif %}
{% endmacro %} |
Not sure to get it: what does the context have when an exception is collected and the trace is displayed? |
I don't know. I guess the exception has nothing. In my case, it was a simple line log with a context. BTW I don't know from where the trace came. I guess it's because the context contained an exception, but I really don't know. Anyway it was not fun to don't see the context. Any way, I going to use the patch from @javiereguiluz ; Thanks. |
OK, got it, a simple log line with an exception, and other things in the context :) |
I updated the PR with the @javiereguiluz' patch. Thanks. Actually he did all the job. |
{% set has_context = log.context is defined and log.context is not empty %} | ||
{% set has_trace = log.context.exception.trace is defined %} | ||
|
||
{% if not has_context and not has_trace %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not has_context is the same
{{ profiler_dump_log(log.message, log.context) }} | ||
|
||
{% set context_id = 'context-' ~ category ~ '-' ~ log_index %} | ||
<div class="text-small font-normal"> | ||
{% if has_context %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR updated.
Thank you @lyrixx. |
…r profiler (lyrixx) This PR was merged into the 3.3 branch. Discussion ---------- [WebProfilerBundle] Display trace and context in the logger profiler | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Right now the behavior is not perfect. It can display only the trace **or** the context. Some time, we want both. More over, using `{{ profiler_dump_log(log.message, trace) }}` is wrong Commits ------- ef1e508 [WebProfilerBundle] Display trace and context in the logger profiler
…e logger profiler (lyrixx) This PR was merged into the 3.3 branch. Discussion ---------- [WebProfilerBundle] Display trace and context in the logger profiler | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Right now the behavior is not perfect. It can display only the trace **or** the context. Some time, we want both. More over, using `{{ profiler_dump_log(log.message, trace) }}` is wrong Commits ------- ef1e508 [WebProfilerBundle] Display trace and context in the logger profiler
Right now the behavior is not perfect. It can display only the trace or the context.
Some time, we want both.
More over, using
{{ profiler_dump_log(log.message, trace) }}
is wrong