Skip to content

Commit 5f96581

Browse files
committed
feature #13418 [DX] Attempt to improve logging messages with parameters (iltar)
This PR was squashed before being merged into the 2.7 branch (closes #13418). Discussion ---------- [DX] Attempt to improve logging messages with parameters | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony/symfony#12594 (comment) | License | MIT | Doc PR | n/a This PR is a follow-up of #12594 `[DX] [HttpKernel] Use "context" argument when logging route in RouterListener`. I have attempted to improve the log messages, as well as updating the usage context. I wasn't sure if the log messages should end with a `.` or not, if so I can update all messages to confirm a standard. Commits ------- ea80c9b [DX] Attempt to improve logging messages with parameters
2 parents acc618f + 2cb1510 commit 5f96581

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

Controller/ControllerResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function getController(Request $request)
5151
{
5252
if (!$controller = $request->attributes->get('_controller')) {
5353
if (null !== $this->logger) {
54-
$this->logger->warning('Unable to look for the controller as the "_controller" parameter is missing');
54+
$this->logger->warning('Unable to look for the controller as the "_controller" parameter is missing.');
5555
}
5656

5757
return false;

EventListener/RouterListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function onKernelRequest(GetResponseEvent $event)
140140
}
141141

142142
if (null !== $this->logger) {
143-
$this->logger->info(sprintf('Matched route "%s"', $parameters['_route']), array(
143+
$this->logger->info(sprintf('Matched route "%s".', $parameters['_route']), array(
144144
'route_parameters' => $parameters,
145145
'request_uri' => $request->getUri(),
146146
));

Profiler/Profiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function saveProfile(Profile $profile)
117117
}
118118

119119
if (!($ret = $this->storage->write($profile)) && null !== $this->logger) {
120-
$this->logger->warning('Unable to store the profiler information.');
120+
$this->logger->warning('Unable to store the profiler information.', array('configured_storage' => get_class($this->storage)));
121121
}
122122

123123
return $ret;

Tests/Controller/ControllerResolverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ControllerResolverTest extends \PHPUnit_Framework_TestCase
2020
public function testGetControllerWithoutControllerParameter()
2121
{
2222
$logger = $this->getMock('Psr\Log\LoggerInterface');
23-
$logger->expects($this->once())->method('warning')->with('Unable to look for the controller as the "_controller" parameter is missing');
23+
$logger->expects($this->once())->method('warning')->with('Unable to look for the controller as the "_controller" parameter is missing.');
2424
$resolver = $this->createControllerResolver($logger);
2525

2626
$request = Request::create('/');

0 commit comments

Comments
 (0)