Skip to content

Commit

Permalink
made some tweaks to error levels
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jun 15, 2011
1 parent 8027eca commit fb24b95
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php
Expand Up @@ -52,6 +52,6 @@ public function startQuery($sql, array $params = null, array $types = null)
*/
public function log($message)
{
$this->logger->info($message);
$this->logger->debug($message);
}
}
Expand Up @@ -58,11 +58,8 @@ public function addListener($eventName, $listener, $priority = 0)
} else {
$typeDefinition = '[?] '.var_export($listener, true);
}
$msg = sprintf('The given callback (%s) for event "%s" is not callable.', $typeDefinition, $eventName);
if (null !== $this->logger) {
$this->logger->err($msg);
}
throw new \RuntimeException($msg);

throw new \RuntimeException(sprintf('The given callback (%s) for event "%s" is not callable.', $typeDefinition, $eventName));
}

parent::addListener($eventName, $listener, $priority);
Expand Down
Expand Up @@ -78,7 +78,7 @@ public function onCoreRequest(GetResponseEvent $event)
$parameters = $this->router->match($request->getPathInfo());

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

$request->attributes->add($parameters);
Expand Down
Expand Up @@ -54,7 +54,7 @@ public function getController(Request $request)
{
if (!$controller = $request->attributes->get('_controller')) {
if (null !== $this->logger) {
$this->logger->err('Unable to look for the controller as the "_controller" parameter is missing');
$this->logger->warn('Unable to look for the controller as the "_controller" parameter is missing');
}

return false;
Expand All @@ -70,10 +70,6 @@ public function getController(Request $request)
throw new \InvalidArgumentException(sprintf('Method "%s::%s" does not exist.', get_class($controller), $method));
}

if (null !== $this->logger) {
$this->logger->debug(sprintf('Using controller "%s::%s"', get_class($controller), $method));
}

return array($controller, $method);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpKernel/Profiler/Profiler.php
Expand Up @@ -89,7 +89,7 @@ public function loadProfile($token)
public function saveProfile(Profile $profile)
{
if (!($ret = $this->storage->write($profile)) && null !== $this->logger) {
$this->logger->err('Unable to store the profiler information.');
$this->logger->warn('Unable to store the profiler information.');
}

return $ret;
Expand Down
Expand Up @@ -49,7 +49,7 @@ public function handle(GetResponseEvent $event)
$this->context->setToken(new AnonymousToken($this->key, 'anon.', array()));

if (null !== $this->logger) {
$this->logger->debug(sprintf('Populated SecurityContext with an anonymous Token'));
$this->logger->info(sprintf('Populated SecurityContext with an anonymous Token'));
}
}
}
Expand Up @@ -48,7 +48,7 @@ public function handle(GetResponseEvent $event)

if ('https' === $channel && !$request->isSecure()) {
if (null !== $this->logger) {
$this->logger->debug('Redirecting to HTTPS');
$this->logger->info('Redirecting to HTTPS');
}

$response = $this->authenticationEntryPoint->start($request);
Expand All @@ -60,7 +60,7 @@ public function handle(GetResponseEvent $event)

if ('http' === $channel && $request->isSecure()) {
if (null !== $this->logger) {
$this->logger->debug('Redirecting to HTTP');
$this->logger->info('Redirecting to HTTP');
}

$response = $this->authenticationEntryPoint->start($request);
Expand Down
Expand Up @@ -56,7 +56,7 @@ protected function attemptAuthentication(Request $request)
{
if ($this->options['post_only'] && 'post' !== strtolower($request->getMethod())) {
if (null !== $this->logger) {
$this->logger->err(sprintf('Authentication method not supported: %s.', $request->getMethod()));
$this->logger->debug(sprintf('Authentication method not supported: %s.', $request->getMethod()));
}

return null;
Expand Down
Expand Up @@ -112,7 +112,7 @@ public final function autoLogin(Request $request)
}

if (null !== $this->logger) {
$this->logger->debug('Remember-me cookie accepted.');
$this->logger->info('Remember-me cookie accepted.');
}

return new RememberMeToken($user, $this->providerKey, $this->key);
Expand All @@ -126,11 +126,11 @@ public final function autoLogin(Request $request)
}
} catch (UnsupportedUserException $unSupported) {
if (null !== $this->logger) {
$this->logger->err('User class for remember-me cookie not supported.');
$this->logger->warn('User class for remember-me cookie not supported.');
}
} catch (AuthenticationException $invalid) {
if (null !== $this->logger) {
$this->logger->err('Remember-Me authentication failed: '.$invalid->getMessage());
$this->logger->debug('Remember-Me authentication failed: '.$invalid->getMessage());
}
}

Expand Down
Expand Up @@ -25,12 +25,11 @@ public function testGetController()

$request = Request::create('/');
$this->assertFalse($resolver->getController($request), '->getController() returns false when the request has no _controller attribute');
$this->assertEquals(array('Unable to look for the controller as the "_controller" parameter is missing'), $logger->getLogs('debug'));
$this->assertEquals(array('Unable to look for the controller as the "_controller" parameter is missing'), $logger->getLogs('warn'));

$request->attributes->set('_controller', 'Symfony\Tests\Component\HttpKernel\ControllerResolverTest::testGetController');
$controller = $resolver->getController($request);
$this->assertInstanceOf('Symfony\Tests\Component\HttpKernel\ControllerResolverTest', $controller[0], '->getController() returns a PHP callable');
$this->assertContains('Using controller "Symfony\Tests\Component\HttpKernel\ControllerResolverTest::testGetController"', $logger->getLogs('debug'));

$request->attributes->set('_controller', $lambda = function () {});
$controller = $resolver->getController($request);
Expand Down

0 comments on commit fb24b95

Please sign in to comment.