Checked log levels
This commit is contained in:
parent
a45d3eeeb6
commit
cdf4b6aa77
@ -76,12 +76,6 @@ class ControllerNameParser
|
||||
|
||||
private function handleControllerNotFoundException($bundle, $controller, array $logs)
|
||||
{
|
||||
if (null !== $this->logger) {
|
||||
foreach ($logs as $log) {
|
||||
$this->logger->info($log);
|
||||
}
|
||||
}
|
||||
|
||||
// just one log, return it as the exception
|
||||
if (1 == count($logs)) {
|
||||
throw new \InvalidArgumentException($logs[0]);
|
||||
|
@ -109,15 +109,11 @@ class RequestListener
|
||||
$request->attributes->add($parameters);
|
||||
} catch (ResourceNotFoundException $e) {
|
||||
$message = sprintf('No route found for "%s %s"', $request->getMethod(), $request->getPathInfo());
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->err($message);
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException($message, $e);
|
||||
} catch (MethodNotAllowedException $e) {
|
||||
$message = sprintf('No route found for "%s %s": Method Not Allowed (Allow: %s)', $request->getMethod(), $request->getPathInfo(), strtoupper(implode(', ', $e->getAllowedMethods())));
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->err($message);
|
||||
}
|
||||
|
||||
throw new MethodNotAllowedHttpException($e->getAllowedMethods(), $message, $e);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ class Debugger implements DebuggerInterface
|
||||
public function log($message)
|
||||
{
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->info($message);
|
||||
$this->logger->debug($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ abstract class UserAuthenticationProvider implements AuthenticationProviderInter
|
||||
return $authenticatedToken;
|
||||
} catch (UsernameNotFoundException $notFound) {
|
||||
if ($this->hideUserNotFoundExceptions) {
|
||||
throw new BadCredentialsException('Bad credentials', 0, $notFound);
|
||||
throw new BadCredentialsException(sprintf('Bad credentials for user "%s"', $username), 0, $notFound);
|
||||
}
|
||||
|
||||
throw $notFound;
|
||||
|
@ -169,7 +169,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
|
||||
private function onFailure(GetResponseEvent $event, Request $request, AuthenticationException $failed)
|
||||
{
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug(sprintf('Authentication request failed: %s', $failed->getMessage()));
|
||||
$this->logger->info(sprintf('Authentication request failed: %s', $failed->getMessage()));
|
||||
}
|
||||
|
||||
$this->securityContext->setToken(null);
|
||||
@ -205,7 +205,10 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
|
||||
private function onSuccess(GetResponseEvent $event, Request $request, TokenInterface $token)
|
||||
{
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug('User has been authenticated successfully');
|
||||
$this->logger->info(sprintf(
|
||||
'User "%s" has been authenticated successfully',
|
||||
$token->getUsername()
|
||||
));
|
||||
}
|
||||
|
||||
$this->securityContext->setToken($token);
|
||||
|
@ -76,7 +76,7 @@ abstract class AbstractPreAuthenticatedListener implements ListenerInterface
|
||||
$token = $this->authenticationManager->authenticate(new PreAuthenticatedToken($user, $credentials, $this->providerKey));
|
||||
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug(sprintf('Authentication success: %s', $token));
|
||||
$this->logger->info(sprintf('Authentication success: %s', $token));
|
||||
}
|
||||
$this->securityContext->setToken($token);
|
||||
|
||||
@ -88,7 +88,7 @@ abstract class AbstractPreAuthenticatedListener implements ListenerInterface
|
||||
$this->securityContext->setToken(null);
|
||||
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug(sprintf("Cleared security context due to exception: %s", $failed->getMessage()));
|
||||
$this->logger->info(sprintf("Cleared security context due to exception: %s", $failed->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ class BasicAuthenticationListener implements ListenerInterface
|
||||
}
|
||||
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug(sprintf('Basic Authentication Authorization header found for user "%s"', $username));
|
||||
$this->logger->info(sprintf('Basic Authentication Authorization header found for user "%s"', $username));
|
||||
}
|
||||
|
||||
try {
|
||||
@ -78,7 +78,7 @@ class BasicAuthenticationListener implements ListenerInterface
|
||||
$this->securityContext->setToken(null);
|
||||
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug(sprintf('Authentication request failed: %s', $failed->getMessage()));
|
||||
$this->logger->info(sprintf('Authentication request failed for user "%s": %s', $username, $failed->getMessage()));
|
||||
}
|
||||
|
||||
if ($this->ignoreFailure) {
|
||||
|
@ -138,7 +138,7 @@ class ContextListener implements ListenerInterface
|
||||
// let's try the next user provider
|
||||
} catch (UsernameNotFoundException $notFound) {
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug(sprintf('Username "%s" could not be found.', $user->getUsername()));
|
||||
$this->logger->warn(sprintf('Username "%s" could not be found.', $user->getUsername()));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -115,7 +115,7 @@ class DigestAuthenticationListener implements ListenerInterface
|
||||
}
|
||||
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug(sprintf('Authentication success for user "%s" with response "%s"', $digestAuth->getUsername(), $digestAuth->getResponse()));
|
||||
$this->logger->info(sprintf('Authentication success for user "%s" with response "%s"', $digestAuth->getUsername(), $digestAuth->getResponse()));
|
||||
}
|
||||
|
||||
$this->securityContext->setToken(new UsernamePasswordToken($user, $user->getPassword(), $this->providerKey));
|
||||
@ -126,7 +126,7 @@ class DigestAuthenticationListener implements ListenerInterface
|
||||
$this->securityContext->setToken(null);
|
||||
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug($authException);
|
||||
$this->logger->info($authException);
|
||||
}
|
||||
|
||||
$event->setResponse($this->authenticationEntryPoint->start($request, $authException));
|
||||
|
@ -88,7 +88,7 @@ class ExceptionListener
|
||||
$token = $this->context->getToken();
|
||||
if (!$this->authenticationTrustResolver->isFullFledged($token)) {
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->info('Access denied (user is not fully authenticated); redirecting to authentication entry point');
|
||||
$this->logger->debug('Access denied (user is not fully authenticated); redirecting to authentication entry point');
|
||||
}
|
||||
|
||||
try {
|
||||
@ -100,7 +100,7 @@ class ExceptionListener
|
||||
}
|
||||
} else {
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->info('Access is denied (and user is neither anonymous, nor remember-me)');
|
||||
$this->logger->debug('Access is denied (and user is neither anonymous, nor remember-me)');
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -88,7 +88,7 @@ class RememberMeListener implements ListenerInterface
|
||||
}
|
||||
} catch (AuthenticationException $failed) {
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug(
|
||||
$this->logger->warn(
|
||||
'SecurityContext not populated with remember-me token as the'
|
||||
.' AuthenticationManager rejected the AuthenticationToken returned'
|
||||
.' by the RememberMeServices: '.$failed->getMessage()
|
||||
|
@ -88,7 +88,7 @@ class SwitchUserListener implements ListenerInterface
|
||||
$this->securityContext->setToken($this->attemptSwitchUser($request));
|
||||
} catch (AuthenticationException $e) {
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug(sprintf('Switch User failed: "%s"', $e->getMessage()));
|
||||
$this->logger->warn(sprintf('Switch User failed: "%s"', $e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -120,7 +120,7 @@ class SwitchUserListener implements ListenerInterface
|
||||
$username = $request->get($this->usernameParameter);
|
||||
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug(sprintf('Attempt to switch to user "%s"', $username));
|
||||
$this->logger->info(sprintf('Attempt to switch to user "%s"', $username));
|
||||
}
|
||||
|
||||
$user = $this->provider->loadUserByUsername($username);
|
||||
|
@ -56,7 +56,7 @@ class UsernamePasswordFormAuthenticationListener extends AbstractAuthenticationL
|
||||
{
|
||||
if ($this->options['post_only'] && 'post' !== strtolower($request->getMethod())) {
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug(sprintf('Authentication method not supported: %s.', $request->getMethod()));
|
||||
$this->logger->err(sprintf('Authentication method not supported: %s.', $request->getMethod()));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -122,15 +122,15 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface
|
||||
throw $theft;
|
||||
} catch (UsernameNotFoundException $notFound) {
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug('User for remember-me cookie not found.');
|
||||
$this->logger->info('User for remember-me cookie not found.');
|
||||
}
|
||||
} catch (UnsupportedUserException $unSupported) {
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug('User class for remember-me cookie not supported.');
|
||||
$this->logger->err('User class for remember-me cookie not supported.');
|
||||
}
|
||||
} catch (AuthenticationException $invalid) {
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug('Remember-Me authentication failed: '.$invalid->getMessage());
|
||||
$this->logger->err('Remember-Me authentication failed: '.$invalid->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user