Skip to content

[WebProfilerBundle] display profiler url in logs #60505

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 4 commits into
base: 7.3
Choose a base branch
from

Conversation

jeremyFreeAgent
Copy link
Contributor

@jeremyFreeAgent jeremyFreeAgent commented May 21, 2025

Q A
Branch? 7.3
Bug fix? no
New feature? yes
Deprecations? no
Issues
License MIT

This add the display of the profiler URL in the log as follows:

[Application] May 21 17:05:15 |DEBUG  | PROFIL See profiler at https://127.0.0.1:8000/_profiler/92ff6e

Thank you @nicolas-grekas for this idea.

Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

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

Nice feature.
Is it something we want to be opt-in using the config? Or the profiler channel is enough if someone wants to silent this log entries.

@@ -4,6 +4,8 @@ CHANGELOG
7.3
---

* Display profiler URL in logs
Copy link
Member

Choose a reason for hiding this comment

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

We are feature freeze for 7.3, hopefully this feature will be for 7.4. You can add the 7.4 title.

return;
}

$this->logger->debug(\sprintf('See profiler at %s', $this->urlGenerator->generate('_profiler', ['token' => $response->headers->get('X-Debug-Token')], UrlGeneratorInterface::ABSOLUTE_URL)));
Copy link
Member

Choose a reason for hiding this comment

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

The logger should do the interpolation. Does it work like this?

Suggested change
$this->logger->debug(\sprintf('See profiler at %s', $this->urlGenerator->generate('_profiler', ['token' => $response->headers->get('X-Debug-Token')], UrlGeneratorInterface::ABSOLUTE_URL)));
$this->logger->debug('See profiler at {profiler_url}', ['profiler_url' => $this->urlGenerator->generate('_profiler', ['token' => $response->headers->get('X-Debug-Token')], UrlGeneratorInterface::ABSOLUTE_URL)]);

Copy link
Contributor

Choose a reason for hiding this comment

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

why not use directly X-Debug-Token-Link header?

jeremyFreeAgent and others added 2 commits May 21, 2025 20:05
@nicolas-grekas
Copy link
Member

Cool thanks for digging this idea 💡;)

Is it something we want to be opt-in using the config?

Please no! That'd ruin the DX improvement this provides!

public static function getSubscribedEvents(): array
{
return [
KernelEvents::RESPONSE => ['onKernelResponse', -2048],
Copy link
Contributor

@94noni 94noni May 21, 2025

Choose a reason for hiding this comment

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

perhaps unrelated, but does the console command terminate event can also be hooked here ?
so both web/cli have this log ?
edit: its done already when profiling cli output, dont know if relevant for log

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