Skip to content

Navigation Menu

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

Conversation

jon-ht
Copy link

@jon-ht jon-ht commented Mar 30, 2024

Q A
Branch? 7.1
Bug fix? no
New feature? yes
Deprecations? no
Issues N/A
License MIT

This is an attempt to add extra data to Logs panel in profiler.

I'm not convinced by this approch but I couldn't find another way to put DebugProcessor as last item. Doing so ensure that when logs are collected, extra property contains all data from previous processors.

I think this PR could help: symfony/monolog-bundle#455 symfony/monolog-bundle#485

Here's an example with Symfony\Bridge\Monolog\Processor\WebProcessor and Monolog\Processor\MemoryUsageProcessor enabled

image

TODO

  • Tests
  • Update changelogs

@jon-ht jon-ht marked this pull request as ready for review March 30, 2024 22:58
@carsonbot carsonbot added this to the 7.1 milestone Mar 30, 2024
@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.1 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

Comment on lines +33 to +36
$processors = $logger->getProcessors();
while ([] !== $logger->getProcessors()) {
$logger->popProcessor();
}
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

Comment on lines +38 to +42
// 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);
}
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.

@javiereguiluz javiereguiluz added the ❄️ Feature Freeze Important Pull Requests to finish before the next Symfony "feature freeze" label Apr 2, 2024
@symfony symfony deleted a comment from carsonbot Apr 7, 2024
@fabpot fabpot removed the ❄️ Feature Freeze Important Pull Requests to finish before the next Symfony "feature freeze" label May 2, 2024
@fabpot fabpot modified the milestones: 7.1, 7.2 May 2, 2024
@fabpot fabpot modified the milestones: 7.2, 7.3 Nov 20, 2024
@fabpot
Copy link
Member

fabpot commented Mar 29, 2025

What's the status of this PR @jon-ht?

@jon-ht
Copy link
Author

jon-ht commented Apr 8, 2025

Hi @fabpot

I didn't take time to push further this PR. I'm still waiting for symfony/monolog-bundle#485 (previously symfony/monolog-bundle#455) to be accepted/merged, this will also resolve #54445 (comment) as pointed out by @smnandre

@stof
Copy link
Member

stof commented Apr 8, 2025

I don't see how the MonologBundle PR would solve this. The DebugProcessor is added by a configurator (to add it conditionally), and so it won't benefit from the fact that processors registered by the MonologBundle compiler pass can be sorted explicitly or no (the configurator will always be called after the method calls added in the service definition)

@jon-ht
Copy link
Author

jon-ht commented Apr 8, 2025

@stof Maybe it's not a requirement for my PR, but the changes I've added to DebugLoggerConfigurator look more like a hack instead of a proper fix

I thought that adding some king of tag priority will have an effect on how/when DebugLoggerConfigurator is called, but I might be wrong

If the diffs here are OK for you, I'm fine. But if not, do you have any idea on how to do this ?

public function pushDebugLogger(Logger $logger): void
{
if ($this->processor) {
$processors = $logger->getProcessors();
while ([] !== $logger->getProcessors()) {
$logger->popProcessor();
}
// 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);
}
}
}

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.

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