Skip to content

[HttpKernel][2.6] Add request uri to Logger context #13321

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions src/Symfony/Component/HttpKernel/EventListener/RouterListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ public function onKernelRequest(GetResponseEvent $event)
}

if (null !== $this->logger) {
$this->logger->info(sprintf('Matched route "%s" (parameters: %s)', $parameters['_route'], $this->parametersToString($parameters)));
$logContext = $parameters + array('request-uri' => $request->getUri());
$this->logger->info(sprintf('Matched route "%s"', $parameters['_route']), $logContext);
}

$request->attributes->add($parameters);
Expand All @@ -150,16 +151,6 @@ public function onKernelRequest(GetResponseEvent $event)
}
}

private function parametersToString(array $parameters)
{
$pieces = array();
foreach ($parameters as $key => $val) {
$pieces[] = sprintf('"%s": "%s"', $key, (is_string($val) ? $val : json_encode($val)));
}

return implode(', ', $pieces);
}

public static function getSubscribedEvents()
{
return array(
Expand Down