8000 [WebProfilerBundle] Redesigned the log section by javiereguiluz · Pull Request #42195 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[WebProfilerBundle] Redesigned the log section #42195

New issue 8000

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, 2021

Conversation

javiereguiluz
Copy link
Member
Q A
Branch? 5.4
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #42155
License MIT
Doc PR -

This PR is not fully polished, but it's ready for review, both code/design and UX/usability. The main missing feature is dark mode styles.

Before

The logs were divided in sections (that's the main issue reported in #42155). If the app had errors, we displayed errors section first:

before-error

If there are no errors but there are deprecations, we display that section:

before-deprecation

Abut filtering data, it depends on each section. For example, some allow to filter by log channel:

before-filter-channel

And others allow to filter by priority:

before-filter-priority

After

This PR proposes to display a single table with all the logs (and separate the "container compilation" logs because they are a bit different than the others):

after-logs

Question: log timestamps now display milliseconds. Do you like this or is it enough with seconds?

Deprecations and errors are now more highlighted on each row (this needs a bit more polishing):

after-deprecation-error

Filters are now super dynamic and always available:

after-filters

Container logs are still available at the bottom of the page:

after-container

So, what do you think?

@Guikingone
Copy link
Contributor

Regarding the question:

log timestamps now display milliseconds. Do you like this or is it enough with seconds?

Milliseconds can be a good approach as it allows to debug easily some actions performed in an asynchronous way and logged.

Depending on workers and commands, a more precise approach is a better idea.

@BeyerJC
Copy link
BeyerJC commented Jul 19, 2021

I like the changes and think it looks great!

The only thing that comes to my mind is that an option to have some kind of default filtering could be a nice addition.

@maidmaid
Copy link
Contributor

The logs explorer of Datadog could be a source of inspiration. The toggle "only/all" is really useful. Moreover, the counter at the end of each filter is also quite useful, we don't need to click on each filter to see if there are associated logs.

@javiereguiluz
Copy link
Member Author
javiereguiluz commented Jul 20, 2021

OK, I've made some changes based on comments here and on Slack.

When you load the logs page, the behavior is the same as before:

  • if there are errors, display those;
  • else if there are deprecations, display those;
  • else display all messages

log-initial

We've also restored the original "log type selector", but simpler than before:

log-type-selector

The log details have been tweaked (note: even we use colors for each log type, no information is conveyed only using color, so this should be 100% accessible):

log-detail

Finally, filters now show a "Select All" and "Select None" to improve productivity:

log-filter

I need to polish some design things (dark mode) but this should be almost ready This is now ready. What do you think?

@fabpot
Copy link
Member
fabpot commented Jul 20, 2021

Looks great!

@ro0NL
Copy link
Contributor
ro0NL commented Jul 21, 2021

log timestamps now display milliseconds. Do you like this or is it enough with seconds?

image

this sends the wrong signal yes

@javiereguiluz
Copy link
Member Author

About the milliseconds, I also see all messages in .000. Am I doing something wrong or is just that Symfony doesn't store milliseconds for logs?

@wouterj
Copy link
Member
wouterj commented Jul 21, 2021

Am I doing something wrong or is just that Symfony doesn't store milliseconds for logs?

Something must be wrong. The timestamps are logged with milliseconds in the log files

@javiereguiluz
Copy link
Member Author

About timestamps, I've checked the $this->data contents of the LoggerDataCollector and we only have simple timestamps. No millisecond information is stored. But it's true that Monolog shows the milliseconds ... so the info must be there somewhere.

About refactoring the entire code of LoggerDataCollector, I think it's out of the scope of this PR. We can do that later in a separate PR (@ro0NL maybe you can help us here, because it looks like you know this well 🙏 ).

@javiereguiluz
Copy link
Member Author
javiereguiluz commented Jul 22, 2021

In 82ea7cb I found the way to store microseconds in debug log messages. Would this be an acceptable solution?

@ro0NL
Copy link
Contributor
ro0NL commented Jul 22, 2021

About refactoring the entire code of LoggerDataCollector, I think it's out of the scope of this PR.

i challenge you to merge new getProcessedLogs into existing getLogs, yes :)

8000
@fabpot
Copy link
Member
fabpot commented Jul 23, 2021

Thank you @javiereguiluz.

@javiereguiluz javiereguiluz deleted the fix_42155 branch July 23, 2021 15:59
This was referenced Nov 5, 2021
<div class="log-filter-content">
<div class="filter-select-all-or-none">
<a href="#" class="select-all">Select All</a>
<a href="#" class="select-none">Select None</a>
Copy link
Member

Choose a reason for hiding this comment

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

those should be <button type=button> rather than <a> tags

document.querySelector('.no-logs-message').style.display = 0 === numVisibleRows ? 'block' : 'none';

// update the selected totals of all filters
document.querySelector('#log-filter-priority .filter-active-num').innerText = (priorities.length === selectedPriorities.length) ? 'All' : selectedPriorities.length;
Copy link
Member

Choose a reason for hiding this comment

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

should be .textContent rather than .innerText to use the standard method

</div>
{% if has_trace %}
{% set trace_id = 'trace-' ~ category ~ '-' ~ log_index %}
<span><a class="btn btn-link text-small sf-toggle" data-toggle-selector="#{{ trace_id }}" data-toggle-alt-content="Hide trace">Show trace</a></span>
Copy link
Member

Choose a reason for hiding this comment

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

using a<button type=button> would be better than a <a> from an accessibility point of view (btw, a <a> without href is not even focusable)

@@ -132,7 +208,7 @@ private function getContainerDeprecationLogs(): array
$logs = [];
foreach (unserialize($logContent) as $log) {
$log['context'] = ['exception' => new SilencedErrorContext($log['type'], $log['file'], $log['line'], $log['trace'], $log['count'])];
$log['timestamp'] = $bootTime;
$log['timestamp'] = (new \DateTimeImmutable())->setTimestamp($bootTime)->format(\DateTimeInterface::RFC3339_EXTENDED);
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this set the timestamp_rfc3339 key instead ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I remember having some problems about this ... and this was the only solution that worked always (the timestamp_rfc3339 key was not always present or something like that). I don't remember the details, sorry!

<td class="font-normal">
{% set context_id = 'context-compiler-' ~ loop.index %}

<a class="btn btn-link sf-toggle" data-toggle-selector="#{{ context_id }}" data-toggle-alt-content="{{ class }}">{{ class }}</a>
Copy link
Member

Choose a reason for hiding this comment

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

should also be a button

@javiereguiluz
Copy link
Member Author

@stof thanks a lot for your review 🙏 Sadly I won't have time to fix these issues soon. So, if someone wants to help here, please submit a PR. Thanks!

'priority' => [
'Debug' => 100,
'Info' => 200,
'Warning' => 300,
Copy link
Contributor
@Amunak Amunak Feb 7, 2022

Choose a reason for hiding this comment

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

Are "notice" level logs omitted here intentionally? I was surprised they disappeared from the profiler and can't say I'm a fan.

I'd also prefer if we could see the log levels of all messages in the profiler, not just warning vs deprecated vs error and such. Seeing the exact level for lower level messages is useful as well in my opinion.

Additionally, an option to filter out deprecations would be amazing.

Copy link
Member

Choose a reason for hiding this comment

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

Please file a new issue for your request. Hardly anyone will read comments on PRs that have been closed months ago.

Copy link
Member

Choose a reason for hiding this comment

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

Or create a PR directly with your proposals :)

fabpot added a commit that referenced this pull request Feb 25, 2022
…ce" filter, log priority, accessibility) (Amunak)

This PR was squashed before being merged into the 5.4 branch.

Discussion
----------

[WebProfilerBundle] Log section minor fixes (missing "notice" filter, log priority, accessibility)

| Q             | A
| ------------- | ---
| Branch?       | 5.4 <!-- see below -->
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #42195 (related)
| License       | MIT
| Doc PR        | ~

This fixes minor front-end issues with the redesigned Log section in WebProfilerBundle.

Marking as bugfix, since technically the redesign removed some features without documenting it - the log level is now visible even for low level logs (debug, notice, info). I have also added the missing "notice" filter and made sure that when a filter is missing the message is shown (fail-safe).

I have also implemented accessibility fixes mentioned in the original PR (#42195) by @stof.

I did not add tests because I have no idea where or how - currently the profiler front-end is not tested (or at least the log section). These changes do not affect the logic behind the panel in a way that could be easily tested.

Screenshot of the changes: notice the visible log levels and added "notice" filter:

![Screenshot of the changes](https://user-images.githubusercontent.com/781546/152992378-89452512-7b94-40b7-9d8e-8f94acc4d058.png)

Commits
-------

1c3b266 [WebProfilerBundle] Log section minor fixes (missing "notice" filter, log priority, accessibility)
fabpot added a commit that referenced this pull request Dec 1, 2022
…late (HypeMC)

This PR was merged into the 5.4 branch.

Discussion
----------

[WebProfilerBundle] Remove redundant code from logger template

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Introduced in #42195, the log trace gets unnecessarily rendered twice:

![image](https://user-images.githubusercontent.com/2445045/198841019-4fce7dce-f32f-42f2-9f55-829fafa0d558.png)

Commits
-------

62237be [WebProfilerBundle] Remove redundant code from logger template
nicolas-grekas added a commit that referenced this pull request May 5, 2023
…Cat)

This PR was merged into the 5.4 branch.

Discussion
----------

[WebProfilerBundle] Remove legacy filters remnants

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | N/A
| License       | MIT
| Doc PR        | N/A

#42195 introduced new filters for the WebProfilerBundle but it still contains some remnants, for example in the translation panel:

> Uncaught TypeError: Sfjs.createFilters is not a function

This PR removes them all.

Commits
-------

98a8aa2 Remove legacy filters remnants
Sign up for free to join this conversation on GitHub. Already have an account? Sign in 9358 to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[WebProfilerBundle] Ability to view all logs together
0