Skip to content

[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

Merged
merged 1 commit into from
Jul 23, 2017

Conversation

lyrixx
Copy link
Member

@lyrixx lyrixx commented Jul 19, 2017

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

@javiereguiluz
Copy link
Member

@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:

before-log

I prefer to put those links in a single line, like the database panel:

db-panel

I've made some changes in the Twig macro to display them like this:

after-log

And this is with both links expanded:

all-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>

                &nbsp;&nbsp;
            {% 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 %}

@nicolas-grekas nicolas-grekas added this to the 3.3 milestone Jul 20, 2017
@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jul 20, 2017

Not sure to get it: what does the context have when an exception is collected and the trace is displayed?

@lyrixx
Copy link
Member Author

lyrixx commented Jul 20, 2017

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.

@nicolas-grekas
Copy link
Member

OK, got it, a simple log line with an exception, and other things in the context :)

@lyrixx
Copy link
Member Author

lyrixx commented Jul 20, 2017

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 %}
Copy link
Member

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 %}
Copy link
Member

Choose a reason for hiding this comment

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

can be removed

Copy link
Member Author

Choose a reason for hiding this comment

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

PR updated.

@fabpot
Copy link
Member

fabpot commented Jul 23, 2017

Thank you @lyrixx.

@fabpot fabpot merged commit ef1e508 into symfony:3.3 Jul 23, 2017
fabpot added a commit that referenced this pull request Jul 23, 2017
…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
@lyrixx lyrixx deleted the logger-panel branch July 23, 2017 11:35
@fabpot fabpot mentioned this pull request Aug 1, 2017
ostrolucky pushed a commit to ostrolucky/symfony that referenced this pull request Mar 25, 2018
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants